[Stackless] Tasklet delays
Richard Tew
richard.m.tew at gmail.com
Thu Dec 10 04:15:11 CET 2009
On Thu, Dec 10, 2009 at 1:40 PM, Jeremy Stott <tins.jeremy at gmail.com> wrote:
> So far I am loving stackless python! I am totally new to it though and was
> wondering about having tasklets wait for a certain amount of time.
>
> The problem is:
> I would like to have a tasklet wait for 2 seconds before returning to the
> scheduling queue, but not delay any other running tasklets.
>
> What I have done:
> timeStart = time.time()
>
> while (time.time() < timeStart + 2):
> stackless.schedule()
>
> But this way does waste resources every scheduling cycle. Is there a better
> way to do this?
Like most things you do with Stackless, you would do this by blocking
the tasklet on a channel.
The Stackless Examples project has source code for a variety of
purposes. For instance, if you take a look at the following page, the
normal and alternative scheduling examples, you can probably see sleep
implementations within them.
http://code.google.com/p/stacklessexamples/wiki/StacklessExamples
Cheers,
Richard.
More information about the Stackless
mailing list