]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-45209: fix `UserWarning: resource_tracker` in test_multiprocessing (GH-28377...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 21 Sep 2021 18:37:04 +0000 (11:37 -0700)
committerGitHub <noreply@github.com>
Tue, 21 Sep 2021 18:37:04 +0000 (20:37 +0200)
(cherry picked from commit f604cf1c377a7648e0686044e6e49900bfc9feef)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Lib/test/_test_multiprocessing.py
Misc/NEWS.d/next/Tests/2021-09-15-23-32-39.bpo-45209.55ntL5.rst [new file with mode: 0644]

index 8f60122cb512e8bb09f3884ac38804b3f16d6c39..6539f250c271a16e1b0aa4dc14b23601b1074054 100644 (file)
@@ -4147,6 +4147,13 @@ class _TestSharedMemory(BaseTestCase):
                                      " 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 (file)
index 0000000..4c3bed0
--- /dev/null
@@ -0,0 +1,2 @@
+Fix ``UserWarning: resource_tracker`` warning in
+``_test_multiprocessing._TestSharedMemory.test_shared_memory_cleaned_after_process_termination``