[Stackless] A select() method, stackless.run() Re: Stackless Digest, Vol 23, Issue 4

Andrew Francis andrewfr_ice at yahoo.com
Fri Dec 16 01:15:04 CET 2005


Hello Christian and Colleagues:

> I am interested in coming up with generalised code
> that
> in a "debugger" mode will "dump" the channels and
the
> tasks.

>So I made new versions of channels and tasklets by
deriving,
>and then patched them into the stackless module at
runtime.
>Easy and works quite fine. Just make sure that your
patching
>code is run prior to any imports of the module.

Okay, I have a naive question. In my example, I have
the form:

a = tasklet()()
b = tasklet()()
c = tasklet()()
.
.
.

print "---begin--"
stackless.run() # I guess stackless.schedule() would
work too
print "--finish--"

I am assuming that in this form, stackless.run()
returns after
all tasklets are finished. So in a sense it also acts
as a 
barrier synchroniser. Would this be safe to assume?

>TaskletExit is just a subclass of SystemExit, which
is
>meant to terminate a tasklet without promoting an
>exception.

>No, I think in this case it would be best to keep
track
>of all channels and check if they are empty after
run().

I guess I would place a debug or an assert after a
run()?

stackless.run()

if __debug__:
   if stackless.getruncount() != 1 :
      raise _______

or

if __debug__:
   for channel in channelsL
       if channel.balance != 0:
          raise

>I think we can make things easier by thinking of a
construct
>that allows to wait on more than one channel at a
time.
>This can probably be written on top of the builtin
stuff.
>It needs a bit of abstraction, of course.

A method that looks similar to the BSD Socket select()
function
springs to mind. Handles both reading and writing and
perhaps opens the door to a smoother integration of
IO?

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