ยปCore Development>Code coverage>Lib/test/subprocessdata/sigchild_ignore.py

Python code coverage for Lib/test/subprocessdata/sigchild_ignore.py

#countcontent
1n/aimport signal, subprocess, sys, time
2n/a# On Linux this causes os.waitpid to fail with OSError as the OS has already
3n/a# reaped our child process. The wait() passing the OSError on to the caller
4n/a# and causing us to exit with an error is what we are testing against.
5n/asignal.signal(signal.SIGCHLD, signal.SIG_IGN)
6n/asubprocess.Popen([sys.executable, '-c', 'print("albatross")']).wait()
7n/a# Also ensure poll() handles an errno.ECHILD appropriately.
8n/ap = subprocess.Popen([sys.executable, '-c', 'print("albatross")'])
9n/anum_polls = 0
10n/awhile p.poll() is None:
11n/a # Waiting for the process to finish.
12n/a time.sleep(0.01) # Avoid being a CPU busy loop.
13n/a num_polls += 1
14n/a if num_polls > 3000:
15n/a raise RuntimeError('poll should have returned 0 within 30 seconds')