[Twisted-Python] Asynchronicity

Jean-Paul Calderone exarkun at divmod.com
Sat Jun 9 11:33:44 EDT 2007

On Sat, 09 Jun 2007 16:09:29 +0100, Simon Pickles <sipickles at hotmail.com> wrote:
>I have managed to get a simple server going. It seems to accept multiple
>connections correctly.
>I am a little puzzled as to how to achieve an asynchonous application
>using twisted. Twisted itself seems asynchronous, but my code is blocked
>by the call:

Quite so.  reactor.run enters the Twisted mainloop and does not return
until the mainloop is stopped (via reactor.stop).

>Is there anyway I can return from the reactor to run other code, like
>GUI stuff, or other processing?

No, but you can call into your other code from Twisted event handlers or
you can write a custom reactor which integrates an existing mainloop with
Twisted's.  As far as GUIs go, Twisted already includes reactors which
integrate glib, gtk, gtk2, various kinds of Windows loops, wxPython, and
a few others.

Precisely how you integrate two mainloops depends on various details
about the loops in question.  Which GUI library are you trying to
integrate with?


More information about the Twisted-Python mailing list