mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
bpo-36867: _test_multiprocessing: avoid weak sync primitive (GH-13292)
Avoid weak sync primitive in multiprocessing resource_tracker test.
This commit is contained in:
parent
3ea702eca1
commit
cbe72d8426
1 changed files with 12 additions and 4 deletions
|
@ -3945,11 +3945,19 @@ class _TestSharedMemory(BaseTestCase):
|
||||||
# segment should not leak the given memory segment.
|
# segment should not leak the given memory segment.
|
||||||
p.terminate()
|
p.terminate()
|
||||||
p.wait()
|
p.wait()
|
||||||
time.sleep(1.0) # wait for the OS to collect the segment
|
|
||||||
|
|
||||||
# The shared memory file was deleted.
|
deadline = time.monotonic() + 60
|
||||||
with self.assertRaises(FileNotFoundError):
|
t = 0.1
|
||||||
smm = shared_memory.SharedMemory(name, create=False)
|
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':
|
if os.name == 'posix':
|
||||||
# A warning was emitted by the subprocess' own
|
# A warning was emitted by the subprocess' own
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue