Writing traceback

Discussion in 'Python' started by Ehab Teima, Aug 11, 2004.

  1. Ehab Teima

    Ehab Teima Guest

    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'
     
    Ehab Teima, Aug 11, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dave Harris

    IDLE traceback on sys.exit()

    Dave Harris, Nov 2, 2003, in forum: Python
    Replies:
    0
    Views:
    389
    Dave Harris
    Nov 2, 2003
  2. Jan Decaluwe
    Replies:
    0
    Views:
    326
    Jan Decaluwe
    Nov 7, 2003
  3. leroybt.rm
    Replies:
    2
    Views:
    660
    Christopher Koppler
    Nov 26, 2003
  4. Dan Stromberg
    Replies:
    1
    Views:
    307
    Piet van Oostrum
    Dec 2, 2010
  5. Jack Bates
    Replies:
    0
    Views:
    295
    Jack Bates
    May 2, 2011
Loading...

Share This Page