[Stackless] Why can't I use nanosleep() to suspend the execution of a stackless tasklet?

Bin Huang bin.arthur at gmail.com
Thu Sep 19 18:52:10 CEST 2013


Thanks, Rich. What I did not fully understand before was that the tasklets
are all part of the one thread. I just found the stackless SVN repository
with talks and documents in google code. Those are excellent resources for
me to understand the stackless. And I suggest putting a link to the SVN
repository on www.stackless.com. Or maybe not if www.stackless.comis
depleted...

Now my question is, how can stackless take advantage of multiple cores on
my machine since there is essentially only one thread? Tasklet is designed
to reduce overhead but not for parallel hardware, right? It seems natural
to me to combine stackless with classic 'threading' and 'multiprocessing'
modules in Python, which is hinted by the examples in the SVN repository.
But I haven't found any document talking about this issue yet.

Thanks.



On Wed, Sep 18, 2013 at 1:32 PM, Richard Tew <richard.m.tew at gmail.com>wrote:

> You have to run the scheduler to get tasklets to run and be switched
> between.  Remember that the tasklets are all part of the one thread
> they are running on.  So you need to run the thread, to run the
> tasklets.  If you use some external functionality to block the thread,
> then the thread is going to be... blocked.  It will not be able to run
> your code, which runs the scheduler.  nanosleep, whatever that is,
> obviously blocks the thread until it completes.
>
> If you need to make a single tasklet sleep, then you need to write
> further logic to more intelligently run the scheduler.  Or you can
> install stacklesslib, which has implemented this functionality
> already.
>
>
> On 9/19/13, Bin Huang <bin.arthur at gmail.com> wrote:
> > Hi list,
> >
> > I am working on a project that is based on stackless Python. I tried to
> > suspend the execution of a stackless tasklet from a Python C module
> > extension by calling nanosleep(). The Python C module that calls
> > nanosleep() is embedded inside the tasklet handler. However, my approach
> > does not work as I expected. It seems that the entire stackless
> interpreter
> > is suspended. And all tasklets had to delay (instead of sleeping) for the
> > interval time I assigned to nanosleep(). (I tried up to 10 second
> interval
> > so I could clearly see it).
> >
> > I also tried using sleep() in the Python C module extension and I
> observed
> > the same phenomenon.
> >
> > I know I could use stackless.schedule() to suspend a tasklet. But I am
> > still interested in why nanosleep() did not work in my experiment. Is it
> > because nanosleep() suspend the execution of the stackless scheduler?
> >
> > I can post my source code if needed. Thanks in advance.
> >
> > Bin
> >
>
> _______________________________________________
> Stackless mailing list
> Stackless at stackless.com
> http://www.stackless.com/mailman/listinfo/stackless
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.stackless.com/pipermail/stackless/attachments/20130919/06add49c/attachment.html>


More information about the Stackless mailing list