[Stackless] An idea for making Stackless more naturally Re: Stackless Digest,

Andrew Francis andrewfr_ice at yahoo.com
Mon Sep 4 22:02:01 CEST 2006


Hello Richard:

I have been considerable work with Stackless and
asynchronous I/O. 

>I will explain it in this paragraph, so skip it if
you >already understand. Blocking synchronous
operations, >like file IO or networking calls, block
the whole >interpreter.  By doing these operations
asyncronously
>or farming out the blocking to a thread, we can in
the >meantime block the calling tasklet on a channel
until >we have the result, which we can then send to
it >through the channel letting it continue where it
was.  >And because the interpreter carries on while
threads
>or asynchronous operations do the work the
interpreter >would otherwise block for, can continue
to be >scheduled.

I have been developing a web application that can
simultaneously issue and receive web service requests.
I am finally having success. I ended up using Twisted
after using other asynchronous HTTP server and client
libraries. 

My architecture is layered. I run the I/O in its own
'subsystem' and using channels, send messages to the
upper layer that does domain specific work. So I
circumvent many of the problems associated with
reading socket I/O.

A big problem was when a "receive" was issued first.
This would block the application. I got around the
problem by using Twisted taskLoop to call schedule()
at regular intervals. 

I have not looked at how taskLoop() is implemented. I
suspect it may be using the timeout feature of
accept(). What I am concerned about is that the
solution works and the ramifications of what happens
if the timing interval is too small. Do callbacks get
stacked? Or eventually lost?

>Now, the natural next step from this is to replace
all >blocking calls in the builtins, standard lib or
>whatever with similar support. 

Richard, I think Stackless users would get much more
bang for the buck if Stackless could work more
seemlessly with Twisted. Perhaps in the end, this
entails getting Stackless to seemlessly work with low
level asynchronous socket I/O, as you and Andrew
suggested. Or maybe it is just a case of getting
Twisted to run its own thread in the Stackless VM and
modifying channels to work with it? I have to think
about this.

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