[Stackless] Stackless Digest, Vol 92, Issue 6

Andrew Francis andrewfr_ice at yahoo.com
Fri Sep 9 23:35:41 CEST 2011

Hi Kristjan:

Message: 4
Date: Fri, 9 Sep 2011 18:37:27 +0000
From: Kristj?n Valur J?nsson <kristjan at ccpgames.com>
To: The Stackless Python Mailing List <stackless at stackless.com>
Subject: Re: [Stackless] tasklets on threads
    <EFE3877620384242A686D52278B7CCD3181BA9 at RKV-IT-EXCH104.ccp.ad.local>
Content-Type: text/plain; charset="iso-8859-1"

 all of this comes from a desire to hand off jobs to tasklets on other 
threads.  What I am aiming to add is a way to figure out if that thread 
is "blocked", i.e. that it is >waiting for stuff to do.  Since tasklets 
are associated with threads, my current idea is to add an attribute to 
tasklets, something like tasklet.idle, which would be True if that 
>tasklet's thread is idle.   A pool of such threads could then be 
maintained and a job can be handed off to one of them, depending on 
their idlestate, using channels.  No need to >mess around with locks and 
condition variables and whatnot.

I haven't used tasklets with other threads for a while. I figure the motivation to spawn threads is to isolate operations that are CPU intensive or potentially long blocking. Here is a suggestion, inspired in part by the Go language. Create new stackless function that would a create secondary schedulers that run in new thread. Abstract away thread creation. Secondary schedulers would work like the main scheduler with one exception: if there is at least one tasklet is blocked on a channel shared by another tasklet/scheduler, the secondary scheduler (and with it the thread) will not terminate. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20110909/eaf2122f/attachment.html>

More information about the Stackless mailing list