[Twisted-Python] Twisted Signal Handler and wxPython

Thorsten Henninger henni at brainbot.com
Tue Nov 25 11:18:27 EST 2003


Hi,

I had a problem using wxPython together with twisted.
The following code shows, that one has to start the reactor with the 
flag "installSignalHandlers=0", otherwise an SystemError occures.
How does this affect my Twsited-Application?

regards,

Thorsten

import traceback
from wxPython.wx import *
from twisted.internet import  reactor


class MyApp(wxApp):
    def OnInit(self):

        # Twisted Reactor Code
        print "reator start running"
        #reactor.startRunning(installSignalHandlers=0)
        #reactor.startRunning(installSignalHandlers=1)
        timerid = wxNewId()
        EVT_TIMER(self,timerid,self.OnTimer)
        self.timer=wxTimer(self,timerid)
        self.timer.Start(100,True)
        # End Twisted Code
    # Do whatever you need to do here
       
        return True

    def OnTimer(self,event):
        reactor.runUntilCurrent()
        reactor.doIteration(0)


def main():
    """
    """
   
    try:
        app = MyApp(0)
        print "CALLING MAIN LOOP"
        app.MainLoop()
        print "MAIN LOOP DONE"
    except SystemExit, err:
        print err
    except:
        exc_info = sys.exc_info()
        print "--------------------- CAUGHT EXCECPTION:", exc_info
        traceback.print_exc(file=sys.stdout)
       

if __name__ == "__main__":
    try:
        main()
    finally:
        print "MAIN THREAD HAS EXITED"


The following error occures on Windows 2000, Python 2.3.2 and wxPython 
2.4.2:

D:\Python23\lib\fcntl.py:7: DeprecationWarning: the FCNTL module is 
deprecated; please use fcntl
  DeprecationWarning)
reator start running
--------------------- CAUGHT EXCECPTION: (<class exceptions.SystemError 
at 0x007780F0>, <exceptions.SystemError instance at 0x011775D0>, 
<traceback object at 0x011775F8>)
Traceback (most recent call last):
  File "E:\bbot\nextbot\gui\wxpython\application.py", line 41, in main
    app = MyApp(0)
  File "D:\Python23\lib\site-packages\wxPython\wx.py", line 1945, in 
__init__
    _wxStart(self.OnInit)
  File "E:\bbot\nextbot\gui\wxpython\application.py", line 18, in OnInit
    reactor.startRunning(installSignalHandlers=1)
  File "D:\Python23\Lib\site-packages\twisted\internet\default.py", line 
115, in startRunning
    self._handleSignals()
  File "D:\Python23\Lib\site-packages\twisted\internet\default.py", line 
87, in _handleSignals
    signal.signal(signal.SIGINT, self.sigInt)
SystemError: error return without exception set

-- 
brainbot technologies AG 
boppstrasse . 64 . 55118 mainz . germany
fon +49 6131 211639-1 . fax +49 6131 211639-2
http://brainbot.com/  mailto:henni at brainbot.com






More information about the Twisted-Python mailing list