Cannot start a thread in atexit callback

Zac Burns zac256 at gmail.com
Tue May 5 22:52:25 EDT 2009


It seems that one cannot start a thread in an atexit callback.

My use case is that I have a IO heavy callback that I want to run in a
thread so that other callbacks can finish while it's doing it's thing
to save on exit time.

Example code (py3k)
############################################
import threading
import time
import atexit

def print_():
    print(1)
    time.sleep(1)
    print(2)

def test():
    threading.Thread(target=print_).start()


atexit.register(test)
############################################

--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games



More information about the Python-list mailing list