[Stackless] tasklets on threads

Kristján Valur Jónsson kristjan at ccpgames.com
Fri Sep 9 20:37:27 CEST 2011

Hm, you are probably right.  Maybe Im just fussing about.  I'll have to go and investigate some more.

Btw, 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.

-----Original Message-----
From: stackless-bounces at stackless.com [mailto:stackless-bounces at stackless.com] On Behalf Of Richard Tew
Sent: 9. september 2011 01:24
To: The Stackless Python Mailing List
Subject: Re: [Stackless] tasklets on threads

2011/9/8 Kristján Valur Jónsson <kristjan at ccpgames.com>:
> On Behalf Of Richard Tew:
>> No?  What goes on at interpreter shut down?  Don't we go through the 
>> list of tasklets in some function there killing them?  I seem to 
>> recall fixing a crash bug there at some stage in the past.
> tasklets are killed if their reference goes to zero and they are still alive.  I think we rely on reference counting to do their job.

I dashed off the last email just before I hit the sack, and didn't have the time to search.  But this is what I meant:


  PyThreadState_Clear(PyThreadState *tstate)
  #ifdef STACKLESS


      Py_CLEAR(tstate->st.thread.block_lock); \
      tstate->st.thread.is_blocked = 0;


      slp_kill_tasks_with_stacks(tstate); \


  void slp_kill_tasks_with_stacks(PyThreadState *ts)

Am I missing something, or is this not doing exactly what we are discussing already?

That leaves tasklets without cstates, which should.. be handled nicely.


Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list