[Tutor] building an interactive deamon

Alan Gauld alan.gauld at btinternet.com
Fri Mar 9 23:14:47 CET 2007

"Thanos Panousis" <pthanos at gmail.com> wrote

> How can I make a daemon that does not need to be restarted
> every time a configuration is changed?

There are several ways to do this.
Simplest if you are sleeping for periods is simply to re-read
the config after every wake-up.

Other options incliude using select() I think select will
work for files so if anything changes on the watched file
select will run its code.

> As a side question, is there a more elegant way of making something 
> a deamon
> other than the ole
> while True:
>   do_stuff()
>   sleep(some_time)

select can be used instead of the sleep to only run the code
when an interesting event happens - provided your events are
detectable by select of course!.

The twisted framework should offer some other options too,
but I've never used twisted so am no expert.

Alan G. 

More information about the Tutor mailing list