Skip to content

gh-155003: Don't try to close mmap in SharedMemory.__del__ - #155070

Open
takluyver wants to merge 1 commit into
python:mainfrom
takluyver:fix-issue-155003-b
Open

gh-155003: Don't try to close mmap in SharedMemory.__del__#155070
takluyver wants to merge 1 commit into
python:mainfrom
takluyver:fix-issue-155003-b

Conversation

@takluyver

@takluyver takluyver commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

This is an alternative to #155007, keeping the file descriptor in the object and fixing the __del__ method to close it without trying to close the mmap or memoryview, which was my original idea in #155003.

I could add, in this PR or separately:

  • The same posix_fallocate() change as in gh-155003: Don't keep file descriptor in multiprocessing SharedMemory object #155007 - but with this option it's orthogonal.
  • A public API to access the fd, probably a .fileno() method, which is a convention for higher level objects which wrap an fd.
  • Use mmap(..., trackfd=False) to skip the duplicate fd within mmap (at a cost of breaking potential workarounds using sm._mmap.resize() & .size())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant