durusmail: quixote-users: call a scheduled method
call a scheduled method
2003-07-30
2003-08-05
call a scheduled method
Etienne Posthumus
2003-07-31
On Wed, 30 Jul 2003, Jeff Koncz wrote:
> Where is the best place to put in some code for calling a scheduled method?

> I need to call this thing every 10 minutes.  I'll use some sort of loop with
> time.sleep(600) to get my interval, so no problem there.  I'm just not sure
> where to put this type of code in the application.   It needs to run in the
> same process as my Quixote app.  I use SCGI to serve it so I'm thinking I
> could override main() in scgi.quixote_handler and then put my scheduled
> method code in there.  Is that a good approach?  Any other ideas?

I use Medusa, and in there I made my own loop() method in stead of using
the asyncore.loop. It does exactly the same thing as the asyncore.loop,
but each trip round the loop after falling out of the select call, it
checks a dict of 'scheduled' methods.
If any of the methods scheduled times are < time(), they are executed.

I add methods to be scheduled using a later() method in which I specify
the method, args and time in the future to be called.

Oh yes, the timeout for the select is 0.01.
Not sure if a similar approach is possible in SCGI as I haven't used it
yet. What I like about Medusa is that I don't have to worry about any
threading issues for the called methods

Etienne Posthumus
Programmer, IIDS - Intelligent Interactive Distributed Systems
http://www.iids.org/
Vrije Universiteit Amsterdam
----------------------------

reply