This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author undercoveridiot
Recipients ellisj, mwh, tiagoaoa, undercoveridiot
Date 2009-08-03.22:24:03
SpamBayes Score 1.2829621e-05
Marked as misclassified No
Message-id <1249338245.17.0.425430573854.issue1230540@psf.upfronthosting.co.za>
In-reply-to
Content
Instead of using decorators, this is a slightly simpler modification to
the proposed workaround that allows for any subclassed run method to
also be caught.


def installThreadExcepthook():
    """
    Workaround for sys.excepthook thread bug
    From
http://spyced.blogspot.com/2007/06/workaround-for-sysexcepthook-bug.html
   
(https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1230540&group_id=5470).
    Call once from __main__ before creating any threads.
    If using psyco, call psyco.cannotcompile(threading.Thread.run)
    since this replaces a new-style class method.
    """
    init_old = threading.Thread.__init__
    def init(self, *args, **kwargs):
        init_old(self, *args, **kwargs)
        run_old = self.run
        def run_with_except_hook(*args, **kw):
            try:
                run_old(*args, **kw)
            except (KeyboardInterrupt, SystemExit):
                raise
            except:
                sys.excepthook(*sys.exc_info())
        self.run = run_with_except_hook
    threading.Thread.__init__ = init
History
Date User Action Args
2009-08-03 22:24:05undercoveridiotsetrecipients: + undercoveridiot, mwh, ellisj, tiagoaoa
2009-08-03 22:24:05undercoveridiotsetmessageid: <1249338245.17.0.425430573854.issue1230540@psf.upfronthosting.co.za>
2009-08-03 22:24:03undercoveridiotlinkissue1230540 messages
2009-08-03 22:24:03undercoveridiotcreate