[Python-checkins] bpo-45209: fix `UserWarning: resource_tracker` in test_multiprocessing (GH-28377)
miss-islington
webhook-mailer at python.org
Tue Sep 21 14:19:57 EDT 2021
https://github.com/python/cpython/commit/09e5016f8bb07beb7d780df221febac2d2867ad0
commit: 09e5016f8bb07beb7d780df221febac2d2867ad0
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-09-21T11:19:48-07:00
summary:
bpo-45209: fix `UserWarning: resource_tracker` in test_multiprocessing (GH-28377)
(cherry picked from commit f604cf1c377a7648e0686044e6e49900bfc9feef)
Co-authored-by: Nikita Sobolev <mail at sobolevn.me>
files:
A Misc/NEWS.d/next/Tests/2021-09-15-23-32-39.bpo-45209.55ntL5.rst
M Lib/test/_test_multiprocessing.py
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 8ebcd0d64dfaa..125e8906d8abc 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -4178,6 +4178,13 @@ def test_shared_memory_cleaned_after_process_termination(self):
" a process was abruptly terminated.")
if os.name == 'posix':
+ # Without this line it was raising warnings like:
+ # UserWarning: resource_tracker:
+ # There appear to be 1 leaked shared_memory
+ # objects to clean up at shutdown
+ # See: https://bugs.python.org/issue45209
+ resource_tracker.unregister(f"/{name}", "shared_memory")
+
# A warning was emitted by the subprocess' own
# resource_tracker (on Windows, shared memory segments
# are released automatically by the OS).
diff --git a/Misc/NEWS.d/next/Tests/2021-09-15-23-32-39.bpo-45209.55ntL5.rst b/Misc/NEWS.d/next/Tests/2021-09-15-23-32-39.bpo-45209.55ntL5.rst
new file mode 100644
index 0000000000000..4c3bed0983b89
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2021-09-15-23-32-39.bpo-45209.55ntL5.rst
@@ -0,0 +1,2 @@
+Fix ``UserWarning: resource_tracker`` warning in
+``_test_multiprocessing._TestSharedMemory.test_shared_memory_cleaned_after_process_termination``
More information about the Python-checkins
mailing list