[Twisted-Python] Restarting a reactor listener
glyph at divmod.com
glyph at divmod.com
Tue Aug 1 13:03:11 MDT 2006
On Tue, 1 Aug 2006 13:44:23 -0400, Jean-Paul Calderone <exarkun at divmod.com> wrote:
>On Tue, 01 Aug 2006 19:27:54 +0200, ian.parker at facilita.co.uk wrote:
>>I have created an internet server that is started in a thread from a Python
>>QT GUI.
Although Twisted's QT reactor is not terribly well supported since nobody on the Twisted team likes QT, but starting a reactor in a non-main thread and restarting it is not "not well supported", it is very explicitly broken :).
You should look at using the QT reactor, and run your Twisted code in the same thread as your GUI -- and possibly submitting some patches so we can finally get the last of the tests passing: see http://twistedmatrix.com/buildbot/
If you have the option of using a different UI toolkit, consider using GTK2; GTK seems to behave best out of all the toolkits when dealing with asynchronous I/O, and it is definitely a favorite of a sizeable portion of the Twisted team.
>>When I restart it (...)
As exarkun says, the reactor is not restartable.
There's a reason why nobody's bothered with this yet. While a truly restartable reactor might be of real use in a few obscure situations (mostly in test code), applications which _appear_ to require it are often just mis-designed and should be fixed to run the reactor in the "normal" way.
For a previous discussion of this issue, see this ticket, which seems to be destined for rejection: http://twistedmatrix.com/trac/ticket/893
More information about the Twisted-Python
mailing list