[Stackless] stackless and system threads

Andrew Francis andrewfr_ice at yahoo.com
Sat Feb 3 17:25:15 CET 2007


Hello Andrew :

> Message: 1
> Date: Fri, 2 Feb 2007 15:27:59 -0500
> From: Andrew Dalke <dalke at dalkescientific.com>
> Subject: [Stackless] stackless and system threads
> To: stackless at stackless.com
> Message-ID:
>
<115d0429d704274fcaec543a84a18f87 at dalkescientific.com>
> Content-Type: text/plain; charset=US-ASCII;
> format=flowed
 
> I want to show how to have stackless work with
> system threads, as when dealing with functions which
>have no non-blocking solution.

I need to look at your code in more detail. However I
have had these problems making Stackless interoperate
with the Twisted Networking framework. I do a few
things :

1. Run Twisted and Stackless in seperate threads
(Twisted has a callFromThread() and callInThread
call()).

1A. In my case, I have the Stackless and Twisted
threads share a dequeue. I am being conservative; I
could probably use a channel.

1B. I isolate Twisted and Stackless functionality.

2. From experience, I have found that in order to
avoid Stackless Python's notion of "deadlocking" and
to give various tasklets a chance, I do the following.

Note : note in the case of deque, I have to do this.

while (some_condition):
    #this could be also channel.balance > 0 )
    if len(queue) > 0: 
       message = channel.pop()
       # do something
    else:
       # give non-blocking tasklets a chance
       # I also use the polling to run a "soft" clock
       # for a scheduler.   
    stackless.schedule()

Cheers,
Andrew



 
____________________________________________________________________________________
Finding fabulous fares is fun.  
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.
http://farechase.yahoo.com/promo-generic-14795097

_______________________________________________
Stackless mailing list
Stackless at stackless.com
http://www.stackless.com/mailman/listinfo/stackless



More information about the Stackless mailing list