[Tutor] totally stumped on signal code, wont work in this instance

Kent Johnson kent37 at tds.net
Fri Feb 6 12:33:00 CET 2009


On Fri, Feb 6, 2009 at 4:06 AM, dave selby <dave6502 at googlemail.com> wrote:

> import sys, threading, time, os.path, urllib, time, signal, ConfigParser, logger
> ....
>
> def main():
>
>    while True: # sleep to keep daemons alive :)
>        time.sleep(60 * 60 * 24)
>
>
> def signal_hup(signum, frame):
>    """
>    SIGHUP, unlike all other daemons SIGHUP causes this daemon to exit killing
>    all its daemon threads. This is a workaround. Because 'kmotion_ptzd' is
>    threaded the only way to get the threads to reliably reload their config
>    is to kill and restart else they languish in a sleep state for ? secs.
>
>    args    : discarded
>    excepts :
>    return  : none
>    """
>
>    print 'sighup :)'
>    #logger.log('signal SIGHUP detected, shutting down due to
> threading', 'CRIT')
>    #sys.exit()
>
> ...
> main()

Don't you have to register your handler with something like
signal.signal(signal.SIGHUP, signal_hup)
?

Kent


More information about the Tutor mailing list