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 <[email protected]> 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 [email protected] http://www.stackless.com/mailman/listinfo/stackless
