Skip to content

Commit a735d49

Browse files
committed
fixup! fixup! Ensure the tracker is killed to allow multiple testing runs in the same process
1 parent a7d5c59 commit a735d49

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4478,13 +4478,9 @@ def check_semaphore_tracker_death(self, signum, should_die):
44784478
os.kill(pid, signal.SIGKILL)
44794479
time.sleep(0.5) # give it time to die
44804480
old_stderr = sys.stderr
4481-
r, w = os.pipe()
4482-
# Make the pipe non blocking to not hang indefinitely
4483-
if sys.platform != "win32":
4484-
import fcntl
4485-
fcntl.fcntl(r, fcntl.F_SETFL,
4486-
fcntl.fcntl(r, fcntl.F_GETFL) | os.O_NONBLOCK)
4487-
sys.stderr = open(w, "bw")
4481+
testfn = test.support.TESTFN
4482+
self.addCleanup(test.support.unlink, testfn)
4483+
sys.stderr = open(testfn, "bw")
44884484
try:
44894485
with warnings.catch_warnings(record=True) as all_warn:
44904486
_semaphore_tracker.ensure_running()
@@ -4494,7 +4490,7 @@ def check_semaphore_tracker_death(self, signum, should_die):
44944490
# information.
44954491
_semaphore_tracker._send("PING", "")
44964492
deadline = time.monotonic() + 5
4497-
with open(r, "rb") as pipe:
4493+
with open(testfn, "rb") as pipe:
44984494
while True:
44994495
if time.monotonic() >= deadline:
45004496
raise TimeoutError("Reading data "

0 commit comments

Comments
 (0)