[Stackless] Using stackless for concurrent HTTP calls / amazon simpledb

Richard Tew richard.m.tew at gmail.com
Fri Mar 21 14:52:21 CET 2008


On Fri, Mar 21, 2008 at 5:58 AM, Robert MannI <robmnl at gmail.com> wrote:
>  When I do stackless.run(), are all tasklets run at the same time?   Or
>  are they executed serially, one tasklet staring after the other one
>  has finished executing?

This will schedule cooperatively.  If your tasklets do not yield in
some way, whether stackless.schedule or something else, then they will
run serially.

Keep in mind that IO operations block the interpreter.  This means
that while one tasklet is doing an IO operation, it will block the
whole interpreter and therefore the scheduler.  Typically people use
asynchronous IO with Stackless and wrap it in channels so they can do
what looks like a normal call to it in their tasklets.

The stacklesssocket module does this.  It wraps the asynchronous
networking IO provided by the asyncore module and provides a
replacement socket module.  The idea is that it can be put in place of
the standard socket module and all IO will block calling tasklets
until the result has arrived and then reawaken them, and the scheduler
will continue to run the other tasklets in the meantime.

If you end up using the stacklesssocket module, keep in mind it is not
an optimised or completely tested piece of code.  You can find it
here:
http://code.google.com/p/stacklessexamples/wiki/StacklessNonblockModules
And networking examples, some based on it, here:
http://code.google.com/p/stacklessexamples/wiki/StacklessNetworking

Cheers,
Richard.




More information about the Stackless mailing list