[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

asynchronous timer events - how to?

Helmut Jarausch

1/9/2008 5:00:00 PM

Hi,

I'm using a web server (Karrigell) which is based on the asyncore module.
I'd like to be able to checkpoint some data (e.g. pickled dictionaries) to disk
from time to time.
For that I would need to setup a timer which calls a Python object/function when
its time interval has expired. While this function is running I need access to
the variables of the server.

Can this be done in a simple way?

Many thanks for a hint,

Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
2 Answers

Fredrik Lundh

1/9/2008 5:20:00 PM

0

Helmut Jarausch wrote:

> I'm using a web server (Karrigell) which is based on the asyncore module.
> I'd like to be able to checkpoint some data (e.g. pickled dictionaries) to disk
> from time to time.
> For that I would need to setup a timer which calls a Python object/function when
> its time interval has expired. While this function is running I need access to
> the variables of the server.

the usual way to do that with asyncore is to add an outer control loop
that calls asyncore.loop with a count argument (or poll directly), and
checks a "task queue" at regular intervals.

but in your case, it's probably easier to set up a cron job that does
a "wget" against your server with a "secret" URL, and have the server do
the checkpointing whenever that URL is fetched.

</F>

Helmut Jarausch

1/9/2008 6:31:00 PM

0

Fredrik Lundh wrote:
> Helmut Jarausch wrote:
>
>> I'm using a web server (Karrigell) which is based on the asyncore module.
>> I'd like to be able to checkpoint some data (e.g. pickled
>> dictionaries) to disk
>> from time to time.
>> For that I would need to setup a timer which calls a Python
>> object/function when its time interval has expired. While this
>> function is running I need access to the variables of the server.
>
> the usual way to do that with asyncore is to add an outer control loop
> that calls asyncore.loop with a count argument (or poll directly), and
> checks a "task queue" at regular intervals.
>
> but in your case, it's probably easier to set up a cron job that does
> a "wget" against your server with a "secret" URL, and have the server do
> the checkpointing whenever that URL is fetched.

Thanks for this ingenious idea,
Helmut.

--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany