We were hit by this bug:
http://bugs.python.org/issue1856 Daemon threads segfault during interpreter shut down.
Now I search a way to code around this bug.
At the moment the code looks like this:
while True:
do_something()
time.sleep(interval)
Is there a way to check if the interpreter is still usable before do_something()?
Or is it better to not do mythread.setDaemon(True) and the check if the main thread has exited?
Answer to own question:
I use this pattern now: don't setDaemon(True), don't use sleep(), use parent_thread.join()
while True:
parent_thread.join(interval)
if not parent_thread.is_alive():
break
do_something()
Related: http://docs.python.org/2/library/threading.html#threading.Thread.join
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With