[Twisted-Python] Use asyncore dispatchers with Twisted

Itamar Shtull-Trauring twisted at itamarst.org
Tue Jan 8 17:43:14 EST 2002

Glyph Lefkowitz wrote:

> There has GOT to be a better way to do this :)

Well, two other possibilities:

1) Wrap each dispatcher with a Selectable and plug those in to the 
twisted event loop. I think we'd still need a Delayed to deal with the 
difference between twisted's addReader() and asyncore's readable() (in 
twisted you set yourself, in asyncore the event loop does that for you.)

2) Make asyncore twisted's core event loop - very icky, and possible 
conflicts with other event loops, such as GUI toolkits.

I actually think this way isn't bad - consider that asyncore.loop() does 
basically the same thing as this code. The drawbacks are of course two 
select() calls per loop, and the hardcoded select() timeout - but with 
0.0 it started sucking up all my CPU.

Anyway, the idea is to embrace and assimilate - once we've got them 
hooked with Twisted's *other* cool stuff they'll end up rewriting as a 
Protocol anyway ;)

More information about the Twisted-Python mailing list