-
-
Notifications
You must be signed in to change notification settings - Fork 441
Open
Description
After fork, the thread_info
should be updated, because the tid is inherited from its parent process. So the following happened:
This happens if we use:
os.fork
.multiprocessing
with the start methodfork
.
forkserver
will not lead to this, because we only patch, but not trace.
spwan
will not lead to this as well, because we use exec
.
I've fixed it:
Code to reproduce:
fork
import os
def hello():
print("Hello World", os.getpid())
def child():
print("Child process")
hello()
def parent():
print("Parent process")
hello()
print("Hello World")
pid = os.fork()
if pid == 0:
child()
else:
parent()
os.waitpid(pid, 0)
multiprocessing
with 'fork'
import multiprocessing
import os
def hello():
print("Hello World", os.getpid())
def child():
print("Child process")
hello()
def parent():
print("Parent process")
hello()
print("Hello World")
if __name__ == "__main__":
import multiprocessing as mp
mp.set_start_method("fork")
p = multiprocessing.Process(target=child)
p.start()
p.join()
parent()
Metadata
Metadata
Assignees
Labels
No labels