ANN: kronos, a task scheduler

I

Irmen de Jong

Hello
I've written a task scheduler called "kronos".
This task scheduler is designed to be used from inside your own program.
(i.e. it is not a cron daemon replacement).
You can schedule Python functions to be called at specific intervals or
days. It uses the standard 'sched' module for the actual task scheduling,
but provides much more:
- repeated tasks (at intervals, or on specific days)
- error handling (exceptions in tasks don't kill the scheduler)
- optional to run scheduler in its own thread or separate process
- optional to run a task in its own thread or separate process

It is available from http://www.razorvine.net/download/kronos.py

Because it is the first version I'd like to request feedback from others!
Suggestions, bugs, improvements? Please let me know.

Your input is highly appreciated.

--Irmen de Jong
 
M

Michele Simionato

Irmen de Jong said:
Hello
I've written a task scheduler called "kronos".
This task scheduler is designed to be used from inside your own program.
(i.e. it is not a cron daemon replacement).
You can schedule Python functions to be called at specific intervals or
days. It uses the standard 'sched' module for the actual task scheduling,
but provides much more:
- repeated tasks (at intervals, or on specific days)
- error handling (exceptions in tasks don't kill the scheduler)
- optional to run scheduler in its own thread or separate process
- optional to run a task in its own thread or separate process

It is available from http://www.razorvine.net/download/kronos.py

Because it is the first version I'd like to request feedback from others!
Suggestions, bugs, improvements? Please let me know.

Your input is highly appreciated.

--Irmen de Jong

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?
Thanks,

Michele Simionato
 
I

Irmen de Jong

Michele said:
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.
 
R

rosendo

Irmen de Jong said:
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.

Can you publish some usage or examples or a man pages?.
Will help those who want to use this module! :)
Cheers.
Rosendo.
 
I

Irmen de Jong

rosendo said:
Can you publish some usage or examples or a man pages?.
Will help those who want to use this module! :)

Use the source, Luke! :)

Seriously: there are lots of comments in the Kronos.py source
code. Is there something not clear?
It also contains a ready-to-run example in main()...

I've placed a slightly updated version of the scheduler at
http://www.razorvine.net/downloads.html

--Irmen.
 

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,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top