[Stackless] Stackless / Twisted examples checked into SVN

Richard Tew richard.m.tew at gmail.com
Wed Feb 28 19:46:55 CET 2007


Hi,

Greg Hazel has kindly provided some examples of Twisted use with Stackless.
The links provided here are not to the Python files, but to the SVN log page
where you can choose to view marked up source code or download copies
of the Python files.

# In this example, most of the time is spent in the twisted event loop. This
# approach allows you to control the granularity of tasklet execution based on
# time. At 30fps, a timer executes that schedules stackless tasklets to run - a
# simple tasklet just prints "do-op".
http://svn.python.org/view/stackless/sandbox/examples/twisted_timer.py

# In this example, a large portion of the time is spent in stackless. This
# approach allows you to control the granularity of tasklet execution based on
# cooperative yield points in the tasklet. At 30fps, a timer executes that
# prints the fps. A simple tasklet just prints "." and yields to the reactor.
# The reactor processes all pending events, then reschedules the tasklet.
#
# This example eats a lot of cpu, because no time is spent blocking - the
# control is constantly being passed back and forth between the reactor and
# stackless.
http://svn.python.org/view/stackless/sandbox/examples/twisted_yield.py

# In this example, most of the time is spent in the twisted event loop. This
# approach allows you to control the granularity of tasklet execution based on
# deferred operations a tasklet waits on. At 30fps, a timer executes that
# prints the fps. A simple tasklet begins a deferred operation, and waits for
# the result. During that time, control is returned to the reactor.
#
# Because of the possibility that a deferred operation completes immediately,
# a channel subclass is used to hold the value and return it without any
# rescheduling. stackless.channel.send() would otherwise block the tasklet
# before it could call stackless.channel.receive().
http://svn.python.org/view/stackless/sandbox/examples/twisted_yielddefer.py

Cheers,
Richard.

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



More information about the Stackless mailing list