Writing traceback

E

Ehab Teima

Hello,

I have built a server application. It's multithreaded, and everything
works fine so far. I have only one issue with catching exceptions
after I read the documentation but I can't find any problems yet. I'm
catching all errors throughout the code into a function and I write
the traceback to the server log as well as the screen. That's all. I
need not to save it or anything else. The documentation said the
function (in this example catchError) should not handle exceptions
itself. How would I get around this issue given that writing to the
server log must not stop the server? In other words, the function
itself must handle and ignore any exceptions raised by itself. i.e. I
want to make sure that failing to write to the server log is ignored.

The code I have looks like this:

try:
handleClient(...)
except:
catchError(sys.exc_info())

def catchError(excInfo):
print 'An error occured'
try:
fo=open(log, "w")
print_exc()
print_exc(None, fo)
fo.close()
except:
print 'Could not write to the server log'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top