Cannot start a thread in atexit callback

Z

Zac Burns

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top