Re: execution of timers from other callbacks

On Wed, 17 Dec 2008 15:41:58 -0500
muppet <scott asofyet org> wrote:

Here's the call flow:

         timeout callback
            timeout add
            spin in a loop

Since you didn't return from the timeout callback, the main loop  
didn't run, and therefore your timeout doesn't fire.  You must

a) return from the callback, which implies

   i.  break your work into chunks and handle each chunk in an idle  
   ii.  fork a subprocess to do the work, with pipes for  
communication and all that

b) use a new main loop, as in your non_blocking_delay() function,  
which implies that you are simply waiting for something

c) eat events manually, which implies you're doing real work, and if  
it's going to take a while, you don't want to do it this way

Thanks for the good answer. 

I've seen this behavior myself in scripts, and always just
hacked around it, as in your options.

But now I know why, thanks.


I'm not really a human, but I play one on earth. 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]