[Stackless] Stackless / Networking

ghazel at gmail.com ghazel at gmail.com
Wed Feb 21 00:16:15 CET 2007

> My understanding is that because Stackless and Twisted
> are running in the same thread, when select/poll
> blocks, everything will block. This is what I have
> observed.

It's true, but having a scheduled task will prevent it from blocking longer
than would overlap it.

> >If you need a tasklet to run during that time, you
> >could hook up a tasklet to run concurrently with a
> >coiterator (twisted.internet.task.coiterate).
> >That way specific yield points could schedule the
> >reactor to select/poll for events without blocking
> for >long periods of time.
> I did not see coiterate in my documentation (Twisted
> 2.4). Looking coiterate up at
> http://twistedmatrix.com/documents/current/api/twisted.application.internet.CooperatorService.html
> it seems to be undocumented. That said, I used
> LoopingCall to call schedule() at regular intervals.
> However under certain scenarios I got flaky results
> (lost deferreds, runtime errors). It was a mess.

task.LoopingCall is another method. Basically you want to do
reactor.callLater(0, wakeup), so that no time is spent in select/poll other
than the time to process pending events.
Certainly that would work, so any runtime issues you had with it should be

> When I have time, I will look at coiterate. I am
> always on the lookout for a better way of doing
> things. So far it seems to me that running Stackless
> and Twisted in their own threads seems straightforward
> and safe.

The problem with two threads in my opinion is the multitude of race
conditions and such that arise. If you have a good separation between the
tasklets task and the network tasks, this could be ok. But, if you had a
tasklet for every connection it could get quite difficult to coordinate.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20070220/a2d860c6/attachment.htm>
-------------- next part --------------
Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list