[Twisted-Python] Multiple simultaneous SelectReactors?

Peter Hansen peter at engcorp.com
Mon Apr 14 21:36:06 EDT 2003

There appear to be serious problems in several areas of twisted.internet
if one tries to create multiple SelectReactors to use at the same time.

Why would one want to?  For acceptance testing, when it can be desirable 
that the code under test run in the same process as the test code, but
it's not appropriate to share the Reactor.

I'm working on a few fixes, some of which appear to be latent bugs of
various kinds, but I'm still extremely new at Twisted and won't 
immediately be able to provide nice patches and such.

For now, I mainly have these questions:

1. Is Twisted expected to support this in principle, if not currently
in practice?

2. Are the globals "reads" and "writes" that are used in 
twisted.internet.default there solely for optimization purposes, or is
there some more nefarious purpose?  Is it considered absolutely critical
that this optimization is in place?  (If so, it probably makes it 
impossible to fix this limitation of Twisted.)

3. Is it well-known that the abstract.FileDescriptor class does a quiet
little fallback to the global reactor if you don't pass it a reactor reference, 
and that Port fails to pass in its own reactor reference when it creates
a Server object in doRead()?

We've strung together a variety of little changes in the process of 
figuring this out.  Once we're more confident of what we're doing,
I'd be happy to supply the fixes, but I'm not going to waste my time
if everyone thinks SelectReactor.doSelect() absolutely must do those

Also note: I'm working on the most recent released version, not CVS.
The slightest hint that this stuff is significantly changed in CVS 
will send me there, but until now we weren't confident enough with
Twisted to work from unreleased code.  (Actually, attempting to 
resolve this has slightly lowered my confidence in Twisted, but 
only just a bit.)


More information about the Twisted-Python mailing list