[Twisted-Python] Conflict between Tkinter.mainloop() and twisted.internet.reactor.run()

hz hanks hankshz at gmail.com
Fri Mar 30 18:36:19 EDT 2012

Hi all,

I'm writing a program with Twisted and use Tkinter to realize the GUI
interface. However, it seems that I can not run both
Tkinter.mainloop() and twisted.internet.reactor.run() in the same
thread because they will block the other. I tried to program a button
in Tkinter and when the button is pressed, it will start a new thread
using module threading, and call a function with the contend of

        reactor.listenTCP(PORT, file_trans_service.getFileTransCtrlServFactory()

But it will raise an exception as follows:
--- <exception caught here> ---
  File "F:\Python27\lib\site-packages\twisted\internet\base.py", line
426, in _continueFiring
    callable(*args, **kwargs)
  File "F:\Python27\lib\site-packages\twisted\internet\base.py", line
1164, in _reallyStartRunning
  File "F:\Python27\lib\site-packages\twisted\internet\posixbase.py",
line 292, in _handleSignals
  File "F:\Python27\lib\site-packages\twisted\internet\base.py", line
1129, in _handleSignals
    signal.signal(signal.SIGINT, self.sigInt)
exceptions.ValueError: signal only works in main thread

And I also tried to run twisted.internet.reactor.run() in the main
thread, and use module threading or reactor.callInThread() to run
Tkinter.mainloop(). The interface will be displayed, but not

Any one knows how to solve this problem? I just need a Template to
realize the Twisted with GUI. Very appreciated!


More information about the Twisted-Python mailing list