[Twisted-Python] Reactors

Bob Ippolito bob at redivi.com
Thu Nov 18 03:58:39 EST 2004

On Nov 18, 2004, at 12:14 AM, James Y Knight wrote:

> Currently, cfreactor and IOCP reactor both seem to be in a state of 
> very-brokenness. Itamar tells me wxreactor is also broken, but I have 
> no knowledge of that. GTK and GTK2 reactors have some failures on BB, 
> but I don't think they're in very bad shape really. Windows default 
> reactor also currently has some failures, but I seem to recall it 
> working right in the recent past (besides not being able to spawn 
> processes).

Very test-failness.  I haven't seen a situation where cfreactor doesn't 
actually work in practice since it was changed to handle the GIL 

The way the reactor code is written (not very modularly) leaves only 
two options to make cfreactor cleaner:
- have some naughty hacks in cfreactor [current situation]
- subclass, refactor, or reimplement everything that deals with unix 
file descriptors and make some subtle changes so that they don't 
require said hacks [not interested in doing this]

The problem is that the classes that use file descriptors make certain 
assumptions that are only true for the default (and probably poll) 
reactors.  Particularly, from memory, they don't have to tell the 
reactor when they want to lose connection, and they do something very 
crazy in order to determine when a TCP connection is established.  In 
the case of cfreactor, a wrapper object needs to live on top of the 
sockets so that the reactor will wake up on activity, and without 
proper notifications these objects can't be disposed of.

I'm not so sure those hacks are why it fails tests, though.  I believe 
the reason that cfreactor fails so many tests is because (a) 
reactor.run() doesn't necessarily block (a CFRunLoop may already be 
active) and (b) iteration is a big nasty hack, and nearly all the tests 
depend on (or at least they used to) reactor iteration having very 
specific and deterministic behavior.

Anyway, I simply don't have time or need to maintain cfreactor, 
especially when it works for everything I've thrown at it.  If you want 
to remove it, fine, I don't care that much, but I know a few people are 
using it.


More information about the Twisted-Python mailing list