multiprocessing tests log: UserWarning: resource_tracker: There appear to be 1 leaked shared_memory objects to clean up at shutdown #89372
Description
Activity
0:03:25 load avg: 12.33 [250/427] test_multiprocessing_forkserver passed (...)
/home/vstinner/python/main/Lib/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 1 leaked shared_memory objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d '
/home/vstinner/python/main/Lib/multiprocessing/resource_tracker.py:237: UserWarning: resource_tracker: '/psm_33506d9a': [Errno 2] No such file or directory: '/psm_33506d9a'
warnings.warn('resource_tracker: %r: %s' % (name, e))- added3.11only security fixesonly security fixestestsTests in the Lib/test dirTests in the Lib/test dir
on Sep 15, 2021 I would like to work on this, if no one has started yet.
The problem was in
test_shared_memory_cleaned_after_process_terminationtest.» ./python.exe -m test -v test_multiprocessing_forkserver -m test_shared_memory_cleaned_after_process_termination == CPython 3.11.0a0 (heads/main:09b4ad11f3, Sep 15 2021, 20:50:50) [Clang 11.0.0 (clang-1100.0.33.16)] == macOS-10.14.6-x86_64-i386-64bit little-endian == cwd: /Users/sobolev/Desktop/cpython/build/test_python_14874æ == CPU count: 4 == encodings: locale=UTF-8, FS=utf-8 0:00:00 load avg: 1.98 Run tests sequentially 0:00:00 load avg: 1.98 [1/1] test_multiprocessing_forkserver test_shared_memory_cleaned_after_process_termination (test.test_multiprocessing_forkserver.WithProcessesTestSharedMemory) ... ok /Users/sobolev/Desktop/cpython/Lib/multiprocessing/resource_tracker.py:224: UserWarning: resource_tracker: There appear to be 1 leaked shared_memory objects to clean up at shutdown warnings.warn('resource_tracker: There appear to be %d ' /Users/sobolev/Desktop/cpython/Lib/multiprocessing/resource_tracker.py:237: UserWarning: resource_tracker: '/psm_67480e45': [Errno 2] No such file or directory: '/psm_67480e45' warnings.warn('resource_tracker: %r: %s' % (name, e)) ---------------------------------------------------------------------- Ran 1 test in 0.775s OK == Tests result: SUCCESS == 1 test OK. Total duration: 1.6 sec Tests result: SUCCESSMy patch (location
):cpython/Lib/test/_test_multiprocessing.py
Line 4179 in 51056b4
resource_tracker.unregister(f"/{name}", "shared_memory")With this change no warning is generated:
» ./python.exe -m test -v test_multiprocessing_forkserver -m test_shared_memory_cleaned_after_process_termination == CPython 3.11.0a0 (heads/main:09b4ad11f3, Sep 15 2021, 20:50:50) [Clang 11.0.0 (clang-1100.0.33.16)] == macOS-10.14.6-x86_64-i386-64bit little-endian == cwd: /Users/sobolev/Desktop/cpython/build/test_python_24281æ == CPU count: 4 == encodings: locale=UTF-8, FS=utf-8 0:00:00 load avg: 1.80 Run tests sequentially 0:00:00 load avg: 1.80 [1/1] test_multiprocessing_forkserver test_shared_memory_cleaned_after_process_termination (test.test_multiprocessing_forkserver.WithProcessesTestSharedMemory) ... ok ---------------------------------------------------------------------- Ran 1 test in 0.732s OK == Tests result: SUCCESS == 1 test OK. Total duration: 1.5 sec Tests result: SUCCESSMy other highly-related PR where I refactor several
SharedMemorytests: #28294Thanks Nikita Sobolev for the fix.
On 3.12 on Arch Linux, this error is repeated.
Please open a new issue wirh a reproducer.
UserWarning: resource_trackerin test_multiprocessing #28377UserWarning: resource_trackerin test_multiprocessing (GH-28377) #28499UserWarning: resource_trackerin test_multiprocessing (GH-28377) #28500Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: