I'm using twisted in a thread together with wxPython.
Everything works quite fine, but I'm getting a strange traceback when I exit
here's the scenario:
wx runs in the main thread
twisted runs in a secondary thread which is started like:
_daemon = DaemonLoop(self,self._port)
where Daemonloop is (partial):
def __init__(self, wxEvtHandler, port):
self.ui = UIProxy(wxEvtHandler)
# Run reactor
I stop the application from the main thread using
_daemon.stop() <- should kill the twisted reactor
wx.Exit() <- kills the main thread
The app exits (on linux), but I get this traceback:
Unhandled exception in thread started by <bound method DaemonLoop.__bootstrap
of <DaemonLoop(Thread-1, stopped daemon)>>
Traceback (most recent call last):
File "/usr/lib/python2.3/threading.py", line 451, in __bootstrap
File "/usr/lib/python2.3/threading.py", line 460, in __stop
File "/usr/lib/python2.3/threading.py", line 256, in notifyAll
File "/usr/lib/python2.3/threading.py", line 238, in notify
currentThread() # for side-effect
TypeError: 'NoneType' object is not callable
The problem seems to be on windows. There the app doesn't exit all the time,
just sometimes. On Win the window disappears, but in the process list is
still the application process.
So this looks to me like there are still non daemon threads around which keep
the application from exiting.
On a side note: I'm also using the "deferToThread" method for some longer
running tasks, so it might well be that it's one of those threads causing the
issue. Is there a way to figure out which thread doesn't die?
Any pointers are highly appreciated.
Open Source Solutions 4U, LLC 2570 Fleetwood Drive
Phone: +1 650 872 2425 San Bruno, CA 94066
Cell: +1 650 302 2405 United States
Fax: +1 650 872 2417