FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-155003: Don't try to close mmap in SharedMemory.__del__ by takluyver · Pull Request #155070 · python/cpython · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
11 changes: 7 additions & 4 deletions Lib/multiprocessing/shared_memory.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def __init__(self, name=None, create=False, size=0, *, track=True):

def __del__(self):
try:
self.close()
self._closefd()
except OSError:
pass

Expand Down Expand Up @@ -222,6 +222,11 @@ def size(self):
"Size in bytes."
return self._size

def _closefd(self):
if _USE_POSIX and self._fd >= 0:
os.close(self._fd)
self._fd = -1

def close(self):
"""Closes access to the shared memory from this instance but does
not destroy the shared memory block."""
Expand All @@ -231,9 +236,7 @@ def close(self):
if self._mmap is not None:
self._mmap.close()
self._mmap = None
if _USE_POSIX and self._fd >= 0:
os.close(self._fd)
self._fd = -1
self._closefd()

def unlink(self):
"""Requests that the underlying shared memory block be destroyed.
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix an error in the finalizer of :class:`multiprocessing.shared_memory.SharedMemory`
which could leak a file descriptor.
Loading

Back | FazBrowse Home | New Git URL