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

Patrick M. Nielsen thirsteh at gmail.com
Tue Jun 27 11:44:22 EDT 2006


I had a similar problem, and Radix's threadless Twisted snippet proved to be
a very viable solution

Have a look at:
http://twistedmatrix.com/trac/browser/sandbox/radix/threadless.py?rev=17407

On 6/26/06, Andrew Francis <andrewfr_ice at yahoo.com> wrote:
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060627/b6fb9fe1/attachment.html>


More information about the Python-list mailing list