Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-92408/gh-96026: SharedMemory changes#133227

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
duaneg wants to merge5 commits intopython:main
base:main
Choose a base branch
Loading
fromduaneg:gh-92408

Conversation

duaneg
Copy link
Contributor

@duanegduaneg commentedApr 30, 2025
edited by bedevere-appbot
Loading

This is not for merging so much as discussion. It would probably be best split into several PRs: allowing zero-length shared memory objects at least should be separate, and probably should have its own issue.

`multiprocessing.shared_memory.SharedMemory` currently tries to unlink a POSIXshared memory object if it fails to `mmap` it after opening/creating it.However, since it only catches `OSError`, it fails to do so when opening anexisting zero-length shared memory object, as `mmap.mmap` raises a `ValueError`when given a 0 size.Fix this by catching all exceptions with a bare `except`, so the cleanup is runfor all errors.
… handling`multiprocessing.shared_memory.SharedMemory` currently tries to unlink a POSIXshared memory object if it fails to mmap it after opening/creating it in theconstructor. It does this by calling `cleanup()`, which unregisters the sharedmemory despite it not having been registered. This will trigger a separateexception in the resource tracker.Fix this by calling the low-level unlink directly.
`multiprocessing.shared_memory.SharedMemory` currently attempts to `unlink` aPOSIX shared memory object it has opened or created if a subsequent exceptionis raised in its constructor.This is necessary to avoid it leaking if the shared memory object was createdin the constructor, however it seems inappropriate if it is opening apre-existing shared memory object.Fix this by only unlinking the shared memory object if it was created.
These are allowed by POSIX and it seems more consistent/cleaner to support themthan forcing the user to treat them as a special case.Windows does not support creating a zero-length mapping, and neither does`mmap` on any platform, so skip those operations and assign a zero-lengthbuffer instead.TODO: The way the POSIX/Windows code is interleaved inside if statements makesfor difficult to follow and deeply nested logic. It might be better to refactorthis code and keep the platform-specific logic in separate functions orpossibly even implementation classes.
@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

It appears MacOS has tight limits on name length which the new tests wereexceeding.
@bedevere-app
Copy link

Most changes to Pythonrequire a NEWS entry. Add one using theblurb_it web app or theblurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply theskip news label instead.

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

@gpsheadgpsheadAwaiting requested review from gpsheadgpshead will be requested when the pull request is marked ready for reviewgpshead is a code owner

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@duaneg

[8]ページ先頭

©2009-2025 Movatter.jp