[Dev] Twisted has a home on Chandler Wiki

Anthony Baxter anthony at interlink.com.au
Mon May 31 18:56:40 PDT 2004

Andi Vajda wrote
> With that in mind, my opinion, for what it's worth, is that we should have the
> following threading model:
>   - a UI thread
>   - a twisted thread
>   - a task manager thread pool to which tasks are assigned and scheduled
> All Twisted-based networking should be done via the twisted thread, which
> involves a fair amount of inter-thread communication, but that's what the
> Twisted model is all about isn't it ?

Note that if you're using wx, you really do need a separate thread
for the wx and twisted event loops. If you try to make the twisted
event loop drive the wx event loop you'll find that menus and popup
dialogs spawn a sub-event-loop, and twisted will block while that's
running. If you try to make the wx event loop drive twisted (using
a wxTimer) you run into the wxTimer's essential suckiness - it
guarantees only 1-100 iterations per second (and on windows you're
lucky to get 100.

In twisted there's a 'callFromThread()' method that allows other
threads to inject stuff into the twisted event loop.

I know about this because we hit this problem with shtoom's wx UI.
Check the shtoom svn trunk for example code.

Anthony Baxter     <anthony at interlink.com.au>
It's never too late to have a happy childhood.

More information about the Dev mailing list