Starting Debugger On Errors In Threads
I'm using following trick to get debugger started on error Starting python debugger automatically on error Any idea how to make this also work for errors that happen in newly creat
Solution 1:
I'd say inject that code in the beginning of each Thread's run().
If you don't want to change that code, you could do monkeypatch it e.g. like this:
Worker.run = lambda *a: [init_pdb(), Worker.run(*a)][-1]
Or like this:
defwrapper(*a):
# init pdb here
Worker.run(*a)
Worker.run = wrapper
If you wanna go real hardcore, you can override threading.Thread.start, or possibly threading.Thread altogether before you import other modules, e.g.:
classDebuggedThread(threading.Thread):def__init__(self):
super(DebuggedThread, self).__init__()
self._real_run = self.run
self.run = self._debug_run
def_debug_run(self):
# initialize debugger hereself._real_run()
threading.Thread = DebuggedThread
Post a Comment for "Starting Debugger On Errors In Threads"