Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-36867: Avoid weak syncronization primitive in resource_tracker tests #13292

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3945,11 +3945,19 @@ def test_shared_memory_cleaned_after_process_termination(self):
# segment should not leak the given memory segment.
p.terminate()
p.wait()
time.sleep(1.0) # wait for the OS to collect the segment

# The shared memory file was deleted.
with self.assertRaises(FileNotFoundError):
smm = shared_memory.SharedMemory(name, create=False)
deadline = time.monotonic() + 60
t = 0.1
while time.monotonic() < deadline:
time.sleep(t)
t = min(t*2, 5)
try:
smm = shared_memory.SharedMemory(name, create=False)
except FileNotFoundError:
break
else:
raise AssertionError("A SharedMemory segment was leaked after"
" a process was abruptly terminated.")

if os.name == 'posix':
# A warning was emitted by the subprocess' own
Expand Down