[Stackless] Suggestion for a Solution ? Re: Blocking Problem with Stackless Python and Twisted

Andrew Francis andrewfr_ice at yahoo.com
Mon Jun 26 20:11:23 CEST 2006


Hello Jas, Bob, et al:

> Twisted isn't designed for Stackless integration,
> and the approach  you're taking simply will not
work.
> Twisted does block on reactor.run(), and during
> each runloop iteration it blocks waiting for a
>timeout or network activity (via  select or poll
>usually).

~

> What's the deal with this error from
> stackless.run():

...

>have some reasons to need to be able to run a
>scheduler on another thread... Did someone discover
>some problem? Or is this check just overly
>conservative? (A few simple scheduling experiments
>seem to run without problem...)

>From what I can tell, the only time I really care
about blocking that cuts down overall concurrency is
when I have tasklets running in parallel, and one or
more of those tasklets, at some low level will be
doing an IO operation that can block for an
indeterminate amount of time (i.e., an accept()).

That said, I beleive the the easiest way to get around
this problem is to bite the bullet and run Twisted (or
the programme with blocking IO) in another process. 

In turn, I :

1. create a simple protocol.
2. and have my Stackless process establish a
connection with the process doing the actual IO (some
other IPC could also be used). 
3. Mark the socket as non-blocking (or use MSG_PEEK?)
4. Have tasklets with a network event loop.


#requests
while (some_condition):
     request = requestChannel.receive()
     serverSocket.send(request)
     stackless.schedule()


#responses
while (some_condition):
     if (there is data):
         reply = serverSocket.receive()
         replyChannel.send(reply)
         stackless.schedule()


you get the idea. Comments? Suggestions?

Cheers,
Andrew



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



More information about the Stackless mailing list