sys.traceback + thread

F

fowlertrainer

Hello python-list,

This is a thread's run method.

def run(self):
try:
page=urllib.urlopen(base)
src=page.read()
page=None
self.ResultCode=0
self.ResultSrc=src
except:
self.ResultSrc="An error occured"+
the exception's errormessage !!!
self.ResultCode=1

I use the traceback module in one threaded application.
But I don't use it in multiple threaded app.

What can I use/how can I do in except section to get the exception's
message ?

Please help me.

Thx.
 
D

Duncan Booth

(e-mail address removed) wrote in (e-mail address removed):
This is a thread's run method.

def run(self):
try:
page=urllib.urlopen(base)
src=page.read()
page=None
self.ResultCode=0
self.ResultSrc=src
except:
self.ResultSrc="An error occured"+
the exception's errormessage !!!
self.ResultCode=1

I use the traceback module in one threaded application.
But I don't use it in multiple threaded app.

What can I use/how can I do in except section to get the exception's
message ?

Please help me.

Call sys.exc_info() to get the current exception details, then use the
traceback module to format the information as you require. Or you could
call traceback.print_exc() if you just want to display the exception and
traceback.

sys.exc_info() and print_exc() are both thread safe.
 

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

No members online now.

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,474
Latest member
AntoniaDea

Latest Threads

Top