New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
monkey-patched Thread survives os.fork() #802
Comments
Hello, Thanks for reporting your observations, and sorry for the late reply. Indeed, child threads which are forked is a side effect of monkey patching the stdlib. I don't know if by design of eventlet/greenlet it is voluntary or not, or if we should consider that behavior as a bug. Besides, when I ran this snippet with a monkey patched stdlib, I can observe that at some point the code exit from the infinite loop created in the Without much available design details, lets consider it as a bug for now. |
Here is the strace for the parent process:
And here is the strace for the forked process:
We can observe that both process exited alone without manually killing them. |
Here is a code snippet where the pid is logged: import eventlet
eventlet.monkey_patch() # behavior differs when monkey_patch() is called
import os
import time
import threading
def in_thread():
seq = 0
while True:
print(f"{os.getpid()}: {seq}")
seq += 1
time.sleep(1)
threading.Thread(target=in_thread).start()
os.fork()
time.sleep(10) |
The |
Since fork() only duplicates the calling thread, seeing background threads being duplicated might be surprising.
I know this is a side effect of green thread, but some code might not expect this.
The text was updated successfully, but these errors were encountered: