asynchronous timer events - how to?

  • Thread starter Helmut Jarausch
  • Start date
H

Helmut Jarausch

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
 
F

Fredrik Lundh

Helmut said:
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>
 
H

Helmut Jarausch

Fredrik said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top