You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
If a python process uses os.fork it seems that even with concurreny=multiprocessing no coverage of the child process is generated. Example file below
To Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:
What version of Python are you using?
3.11
What version of coverage.py shows the problem? The output of coverage debug sys is helpful.
7.6.12
What code shows the problem?
This (not the nicest as it's just a quick hack to replicate some of our code)
#!/usr/bin/python3
import os
import tempfile
import time
import traceback
COMPLETE=tempfile.mkstemp()
print(f"Parent pid is {os.getpid()}")
pid = os.fork()
if pid:
print(f"In parent, child is {pid}")
try:
while True:
with open(COMPLETE[1], mode='r') as f:
data = f.readline()
print(f"Data is {data}")
if "Complete" in data:
print(f"Child is complete")
break
time.sleep(5)
finally:
wait_pid = 0
while wait_pid == 0:
wait_pid, rc = os.waitpid(pid, os.WNOHANG)
if wait_pid == 0:
time.sleep(2)
else:
print(f"In child")
time.sleep(10)
print("Leaving child")
with open(COMPLETE[1], mode='w') as f:
f.write("Complete")
os._exit(0)
Then run with coverage run -p --concurrency=multiprocessing test-fork-cover.py
Expected behavior
Expect to see coverage of both sides of the fork
The text was updated successfully, but these errors were encountered:
Describe the bug
If a python process uses
os.fork
it seems that even with concurreny=multiprocessing no coverage of the child process is generated. Example file belowTo Reproduce
How can we reproduce the problem? Please be specific. Don't link to a failing CI job. Answer the questions below:
3.11
coverage debug sys
is helpful.7.6.12
This (not the nicest as it's just a quick hack to replicate some of our code)
Then run with
coverage run -p --concurrency=multiprocessing test-fork-cover.py
Expected behavior
Expect to see coverage of both sides of the fork
The text was updated successfully, but these errors were encountered: