this seems to be the solution: http://code.activestate.com/recipes/496735/
On Aug 25, 3:37 pm, "~levon" <[EMAIL PROTECTED]> wrote: > Hello group, > > in following example, a signal handler is registered and a thread > started. if I call self.doSomethin() directly > the code works as I would expect. as i send a SIGINT shutdown is > called and the script terminates. > > as soon as I call doSomething() in a thread the the SIGINT handler is > never called again and > i have to terminate the script with a SIGTERM or SIGKILL. > > well, i would expect the handler to be called in both cases, am i > missing something? > > by the way. calling os.kill(os.getpid(), signal.SIGINT) works as I > would expect, what > don't is kill -s SIGINT pid # where pid is the actual process id > > the code: > > class Runner(object): > def __init__(self): > print os.getpid() > self.shd = False > signal.signal(signal.SIGINT, self.shutdown) > threading.Thread(target=self.doSomething).start() > # the following works fine: > #os.kill(os.getpid(), signal.SIGINT) > > def doSomething(self): > while not self.shd: > pass > > def shutdown(self, signo, frm): > self.shd = True > > if __name__ == '__main__': > Runner() > > ~levon -- http://mail.python.org/mailman/listinfo/python-list