[Twisted-Python] Threading traceback
Hi everyone, I'm using twisted in a thread together with wxPython. Everything works quite fine, but I'm getting a strange traceback when I exit the application. 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) _daemon.setDaemon(True) _daemon.start() where Daemonloop is (partial): class DaemonLoop(threading.Thread,pb.Referenceable): def __init__(self, wxEvtHandler, port): super(DaemonLoop, self).__init__() self.ui = UIProxy(wxEvtHandler) self.port=port def _error(self,error): if self.ui: self.ui._error(error) def run(self): # Run reactor reactor.run(installSignalHandlers=0) def stop(self): reactor.stop() def connectionLost(self): self.ui.connectionLost() reactor.stop() 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 self.__stop() File "/usr/lib/python2.3/threading.py", line 460, in __stop self.__block.notifyAll() File "/usr/lib/python2.3/threading.py", line 256, in notifyAll self.notify(len(self.__waiters)) 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. Thanks UC -- 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
participants (1)
-
Uwe C. Schroeder