proper execption handling in python server code