[Stackless] Stackless and mysqldb

Andrew Dalke dalke at dalkescientific.com
Mon Jan 14 12:03:17 CET 2008


On Jan 13, 2008, at 11:01 PM, Simon Pickles wrote:
> Say for instance, I want to do a mysql select call, but I don't  
> want to
> block the interpreter waiting for the call to complete.
>
> How can this be achieved in a stackless framework?
>
> Do I still need to use a separate threading.thread to perform the  
> actual
> lockup, keeping the main threadlet running? can I use channels to
> communicate the SQL result from a separate threading.thread to a
> stackless threadlet in main thread?

The existing MySQL interfaces block, which Stackless can't do  
anything about.  Stackless is a cooperative system.

You'll need to put the MySQL call into its own thread, which can  
block without blocking the Stackless runtime.  Send the result back  
to Stackless through a channel.

You may need to take care - Stackless doesn't know about the new  
thread so if no tasklets are running (while blocked waiting for a  
result from the thread) then it will think there's a deadlock and  
exit from its main loop.

There's some back email traffic on this topic, such as the thread  
starting:
   http://www.stackless.com/pipermail/stackless/2007-June/000160.html

When you've got it working, could you write up a recipe about it and  
post it here to help others with the same question?

				Andrew
				dalke at dalkescientific.com






More information about the Stackless mailing list