[Stackless] integrate stackless with other event driven

Andrew Francis andrewfr_ice at yahoo.com
Sat Oct 14 18:13:51 CEST 2006


Hi Jim:

>Hi, I think it might be a common question about
>integrating stackless and  other event driven
>framework. In most cases, the other event driven 
>framework  uses main loop and listening on select()
or >poll() calls like this:
 
The essense of the solution is to call schedule() as
often as possible. 

I believe another Stackless member asked a similar
question in regards to wxPython about six months ago.

>I have a C++ event driven main loop framework that
>embedded the stackless  framework. The only way I can
>make these two framework work together is:  
>switching between two frameworks in a fix time range.
 
>1. timeout the select() call in my C++ main loop
every >few hundreds  milliseconds, 

[lines deleted]
 
>I would like to hear any suggestion / experience in
>this area. Thanks a lot.

This may be tangential but as I mentioned in the
previous post, I used the Twisted Network Framework. I
use Twisted to concurrently send and receive multiple
SOAP calls. 

In my application, BPEL activities/tasklets don't make
direct network calls. The BPEL tasklets make IO
requests and then block on a channel. A networking
system that interacts with Twisted takes care of the
details (I will assume this is akin to your reply
tasklet). When there is a response, it is written to
the blocked activity's channel and the
activity/tasklet resumes work.

The Twisted gotcha is that Twisted blocks in its
reactor.run(). Under the hood, Twisted uses poll() or
its Win32 API equivalent. Some of my tasklets would
block until some IO occured (i.e, an incoming
connection). I believed the blocking would severly cut
down the throughput. I got around this by using the
Twisted method for regularly scheduling an event
(TaskLoop). In my case, I call stackless.schedule() at
one second intervals. In this fashion, any tasklet
that is scheduled, will get a chance to run.

I have yet to stress test this approach but so far I
am acheiving success. I am happy that I don't have to
resort:

1) using C/C++
2) os threads
3) low level networking
4) altering Twisted.

One day, I would like to talk to the Twisted and
Stackless folks to thoroughly understand why the
TaskLoop/schedule works and how it can be improved.
Unfortunately WS-BPEL is a bit esoteric (besides most
WS-BPEL implementations are written in Java) so I
suspect most Stackless Python users don't see how this
information relates to them. 

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