Problem with threads and signals

Jeff Epler jepler at
Wed Mar 17 17:36:25 CET 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:


import threading, os, signal, time

_shutdown = 0

class T(threading.Thread):
    def run(self):
        while not _shutdown:

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:

    while not _shutdown:

if __name__ == '__main__': main()

More information about the Python-list mailing list