[Twisted-Python] Multiple main loops
David Pratt
fairwinds at eastlink.ca
Tue May 2 18:43:21 MDT 2006
glyph at divmod.com wrote:
>
> On Tue, 02 May 2006 12:00:53 -0300, David Pratt <fairwinds at eastlink.ca>
> wrote:
>> Hi. I am hoping you can clarify for me whether it is possible to run
>> multiple independent main loops in Twisted. It is my understanding
>> that this would mean separate independent reactors.
>
> Yep. This is not currently possible. Most importantly there are no
> tests for it, so we would have no idea if it worked. Writing tests for
> race conditions is notoriously hard.
Hi glyph. Have there been previous attempts to run more than a single
reactor together? Does any of this exist anywhere in the history of the
your repository.
>> Googling, I found this patch but after looking into the repository, it
>> was never committed. I would appreciate any comments on the patch or
>> attempts people have made on the integration of a second twisted loop.
>
> This patch was deliberately left uncommitted. It definitely reverses an
> optimization that was demonstrated to improve performance on the
> critical path; it only maybe makes it possible to initialize multiple
> reactors. If you want to write a comprehensive set of unit tests for
> multiple reactors, we might consider doing something like this,
> otherwise the reactor will be left in its current state in order to
> discourage people from attempting to start multiple reactors concurrently.
I understand what you are saying however there is some appeal in
exploring this possibility (if there is a possibility for it to work).
>> At the present time I am using twisted with wxpython with wxpython as
>> main loop and also running a selectreactor instance. Here there are
>> two separate loops, interoperating and operating independently,
>> however they are not both twisted loops.
>
> wxpython is buggy and has terrible event-loop support. Consider using
> PyGTK instead. If you really must use wx, there are a variety of
> mostly-working ways to integrate the mainloop with Twisted without
> resorting to multiple reactors.
I have been using wxpython and twisted together for about a year. They
seem to perform well together and I would have no problem recommending
wxpython for general cross platform gui development. I am using wxpython
only to illustrate that multiple independent loops can work
cooperatively. The target for the multiple reactor possibility is zope
client instances where currently an asyncore loop has been integrated
for zeo support.
Regards,
David
More information about the Twisted-Python
mailing list