[Python-Dev] Is it a Python bug that the main thread of a process created in a daemon thread is a daemon itself?
elizabeth.shashkova at gmail.com
Thu Jun 25 19:23:44 CEST 2015
When I call fork() inside a daemon thread, the main thread in the child
process has the "daemon" property set to True. This is very confusing,
since the program keeps running while the only thread is a daemon.
According to the docs, if all the threads are daemons the program should
exit. Here is an example:
assert not threading.current_thread().daemon # This shouldn't fail
new_pid = os.fork()
if new_pid == 0:
t = threading.Thread(target=parent)
Is it a bug in the CPython implementation?
Also let's assume the second example. I have another non-daemon thread
in the child process and want to detect this situation. Does anybody
know a way to find such fake daemon threads that are really main
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev