do "some action" once a minute
spamspam at spam.eggs
Tue May 9 17:48:41 CEST 2006
On 2006-05-09, Petr Jakes <petr at tpc.cz> wrote:
> I would like to do "some action" once a minute.
You can try the sched module (import sched).
You give it a time at which to call a callback. Then in the callback you
can reset the "alarm" for a minute later, using enterabs.
If the task might take longer than a minute, it just means you'll be
setting an alarm for a time in the past, but it should still get called.
But there is another problem, which is that the queue will presumably
get very big over time, so you'll need to clear it out now and again
with empty()... which means keeping track of the event objects yourself,
which is annoying.
More information about the Python-list