ANN: kronos, a task scheduler

Irmen de Jong irmen at -nospam-remove-this-xs4all.nl
Sat May 22 07:36:38 EDT 2004


Michele Simionato wrote:

> I havent't looked at the code it is unclear to me if kronos is a kind of daemon
> or not: what happens if I reboot my machine? Is it enough to restart kronos 
> in some init script to get the scheduled task to be executed at the right
> times or is it more complicate than that?

Kronos is not a daemon in the "crond" sense.
When started, it runs as a separate thread or process alongside your
own program. It doesn't store or remember the scheduled tasks by itself.
It shouldn't be too hard to make some sort of persistent task definition
(a "kronostab" if you will) and a little bit of extra code that reads
this definition at startup.

Perhaps it is a nice idea to add a feature to kronos that it can store
the scheduled tasks by itself, so that if it is restarted, it re-reads
the previous schedule file and continues where it left off.
However, this may not be possible because the scheduled tasks contain
references to Python functions (or callable objects) that will be called
when the task is due, and those objects plus their environment will
have to be reconstructed too...

Because kronos uses the standard Python "sched" module, it will still
execute the tasks at the correct times because the task is remembered
by an absolute time value (i.e. 'next task is saturday may 22, 22:00').

I just discovered two possible problems with the code that I posted:
it should have thread locking around the scheduler's queue if you use
a separate thread for the scheduler, and want to change the queue after
the scheduler is started.
The second issue is that you cannot change the queue after you
started the scheduler, if using a separate process for the scheduler.


Bye!

--Irmen de Jong.



More information about the Python-list mailing list