[Stackless] stackless and system threads

Andrew Dalke dalke at dalkescientific.com
Sun Feb 4 05:38:26 CET 2007

On Feb 3, 2007, at 11:25 AM, Andrew Francis wrote:
> 1. Run Twisted and Stackless in seperate threads
> (Twisted has a callFromThread() and callInThread
> call()).

It looks like the suggestion should be that all
Stackless code should be run in the same thread.

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

I'll remember to experiment with both variations.

> 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()

This also busy waits, correct?  And that last "schedule()"
line should be indented by one?

It's effectively the same as the code I wrote, with a
reordering for the loop condition to guarantee at least
one looping.

while 1:
     print "thread count", _thread_count
     if _thread_count == 0:

					dalke at dalkescientific.com

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list