This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sobolevn
Recipients sobolevn, vstinner
Date 2021-09-15.20:31:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1631737915.4.0.793288079308.issue45209@roundup.psfhosted.org>
In-reply-to
Content
The problem was in `test_shared_memory_cleaned_after_process_termination` test.

```
» ./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: SUCCESS
```

My patch (location https://github.com/python/cpython/blob/51056b40e711d84692d099ac8970077b33c7fafd/Lib/test/_test_multiprocessing.py#L4179):

```
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: SUCCESS
```

My other highly-related PR where I refactor several `SharedMemory` tests: https://github.com/python/cpython/pull/28294
History
Date User Action Args
2021-09-15 20:31:55sobolevnsetrecipients: + sobolevn, vstinner
2021-09-15 20:31:55sobolevnsetmessageid: <1631737915.4.0.793288079308.issue45209@roundup.psfhosted.org>
2021-09-15 20:31:55sobolevnlinkissue45209 messages
2021-09-15 20:31:55sobolevncreate