Problem with threads and signals
Jeff Epler
jepler at unpythonic.net
Wed Mar 17 11:36:25 EST 2004
The program below works fine on my system (redhat 9)
A few months ago, debian-specific threading problems in Python were
discussed. If you're using Debian, maybe it's relevant:
http://groups.google.com/groups?threadm=a6562e06.0401021352.65aac82b%40posting.google.com
Jeff
import threading, os, signal, time
_shutdown = 0
class T(threading.Thread):
def run(self):
while not _shutdown:
time.sleep(1)
def shutdown(signum, arg):
global _shutdown
print "Shutting down..."
_shutdown = 1
def main():
print "PID:", os.getpid()
signal.signal(signal.SIGUSR1, shutdown)
threads = [T(), T()]
for th in threads:
th.start()
while not _shutdown:
time.sleep(60)
if __name__ == '__main__': main()
More information about the Python-list
mailing list