[Twisted-Python] Two main loops

Jasper jasper at peak.org
Mon Nov 12 13:47:50 EST 2007


Jean-Paul Calderone wrote:
> On Mon, 12 Nov 2007 08:58:55 -0800, Jasper <jasper at peak.org> wrote:
>> Maarten ter Huurne wrote:
>>> Why would that happen?
>>>
>>> Twisted never blocks; if it has to wait for something (such as a 
>>> transmission buffer becoming ready to accept more data), it will 
>>> register a callback and the reactor will continue (and call your 
>>> rendering code).
>>>
>>> Bye,
>>>                 Maarten
>>>
>>
>> Maybe I'm misunderstanding what's going on underneath, but Twisted 
>> sure seems to block while I send one large chunk of data.
>
> There are a lot of different pieces in any non-trivial program.  There 
> are
> also at least a couple different meanings for the word "block".
[further elaboration snipped]


I think the confusion here is stemming from us attaching different 
meanings to "Twisted".  I've been meaning the entire package, i.e. the 
modules I got when I installed Twisted.  You (Glyph, Maarten, etc.) seem 
to mean only the lower level inner bits, like reactor.  I'd actually 
understood this when I sent the above, and I apologize for the snarky 
reply. ;-)

To get to the point, I actually do feel that the fault lies with 
Twisted, or more specifically PB.  Code using PB wants to be as unaware 
of the details of network transmission as possible.  It certainly 
doesn't want to slice things into a bazillion chunks for individual 
transmission, and then puzzle them back together on the other end.

IMHO it makes more sense for PB to understand it shouldn't block, and to 
chunk and schedule its serialization (and unserialization) in the same 
manner as the TCP packets sent underneath.  I'm guessing this would make 
for cleaner separation, and more general usefulness.

Also, let me clarify that I'm not suggesting that someone else do this, 
nor bitching and moaning about what I'm getting out of a free project; 
it's something I intend to do myself as I have time.

-Jasper





More information about the Twisted-Python mailing list