[Stackless] Stackless and mysqldb

Simon Pickles sipickles at hotmail.com
Mon Jan 14 12:48:56 CET 2008



Andrew Dalke wrote:
> 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
>
>
>
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless
>
>
>   
Hi Andrew, thanks for the reply.

I think I have experienced the deadlock-causing-exit already!  To 
counter this, can I just keep a monitoring tasklet running to keep the 
main tasklet alive?

I am planning on building a demo based on the stacklessFileNonBlocking 
example, this time with a SQL connection per thread. I'll let you know 
when I complete it (I mean - get stuck!)

Regards

Simon

-- 
Linux Counter: User# 424693 







More information about the Stackless mailing list