<div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">The problem I see is that the Twisted scheduled task<br>(a callback) ought to call schedule() to give other
<br>tasklets a chance to run. I don&#39;t had a good mental<br>model of what is happening between between Twisted<br>callbacks and Stackless tasklets in this scenario.</blockquote>
<div>&nbsp;</div>
<div>So you could approach it one of two obvious ways. Either you could have&nbsp;Twisted periodically call&nbsp;stackless.schedule(), on say a LoopingCall. This would work if your tasklets need to run every so often - you control the granularity of how often they run.&nbsp;Otherwise a scheduling Stackless tasklet could occasionally queue up an event to reschedule (
reactor.callLater(0, stackless.schedule)), and then call schedule() itself to let other tasklets run. The allows you to control the granularity in a tasklet instead of time-based.</div>
<div>&nbsp;</div>
<div>I use a third mechanism, which is that tasklets use channels to &quot;block&quot; until a deferred they&#39;re waiting on completes - the deferred is given a callback that sends the result back to the channel then calls 
stackless.schedule.</div><br>-Greg</div>