sys.traceback + thread

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • fowlertrainer@anonym.hu

    sys.traceback + thread

    Hello python-list,

    This is a thread's run method.

    def run(self):
    try:
    page=urllib.url open(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.

    --
    Best regards,
    fowlertrainer mailto:fowlertr ainer@anonym.hu


  • Duncan Booth

    #2
    Re: sys.traceback + thread

    fowlertrainer@a nonym.hu wrote in news:mailman.26 4.1070976113.16 879.python-
    list@python.org:
    [color=blue]
    > This is a thread's run method.
    >
    > def run(self):
    > try:
    > page=urllib.url open(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.[/color]

    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.

    --
    Duncan Booth duncan@rcp.co.u k
    int month(char *p){return(1248 64/((p[0]+p[1]-p[2]&0x1f)+1)%12 )["\5\x8\3"
    "\6\7\xb\1\x9\x a\2\0\4"];} // Who said my code was obscure?

    Comment

    Working...