]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-91577: SharedMemory move imports out of methods (#91579)
authorsamtygier <samtygier@yahoo.co.uk>
Thu, 16 Jun 2022 13:41:51 +0000 (14:41 +0100)
committerGitHub <noreply@github.com>
Thu, 16 Jun 2022 13:41:51 +0000 (15:41 +0200)
commit9a458befdd68625d088f4fea7df135a57d147deb
treeb31d13db745f5d486d75cf112e9e2a554e47fbaf
parenta38c2a61d585fce0973e93dd590551ccddd947fb
gh-91577: SharedMemory move imports out of methods (#91579)

SharedMemory.unlink() uses the unregister() function from resource_tracker. Previously it was imported in the method, but this can fail if the method is called during interpreter shutdown, for example when unlink is part of a __del__() method.

Moving the import to the top of the file, means that the unregister() method is available during interpreter shutdown.

The register call in SharedMemory.__init__() can also use this imported resource_tracker.
Lib/multiprocessing/shared_memory.py
Misc/NEWS.d/next/Library/2022-04-15-17-38-55.gh-issue-91577.Ah7cLL.rst [new file with mode: 0644]