Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiprocessing.managers. SharedMemoryManager should let you name the created object #101014

Open
slerman12 opened this issue Jan 13, 2023 · 2 comments
Labels
3.13 bugs and security fixes topic-multiprocessing type-feature A feature request or enhancement

Comments

@slerman12
Copy link

slerman12 commented Jan 13, 2023

Python's new truly-shared memory (https://docs.python.org/3/library/multiprocessing.shared_memory.html) is great, however using the SharedMemoryManager is impractical since the created list or numpy array can't be custom-named.

Why would we want to custom-name?

Well, say process 3 creates a new object and process 5 wants to access it. Without a shared naming protocol, this isn't possible. Process 3 has to read the name for its newly created object and somehow signal it to process 5 in order for process 5 to ever know about it and access it.

We should be able to name the objects created with the SharedMemoryManager, with the name= parameter, same as the syntax for creating those objects without the manager.

Thanks,
Sam

Linked PRs

@slerman12 slerman12 added the type-feature A feature request or enhancement label Jan 13, 2023
knwng pushed a commit to knwng/cpython that referenced this issue Feb 23, 2023
knwng added a commit to knwng/cpython that referenced this issue Feb 23, 2023
knwng added a commit to knwng/cpython that referenced this issue Feb 23, 2023
knwng added a commit to knwng/cpython that referenced this issue Feb 23, 2023
knwng added a commit to knwng/cpython that referenced this issue Feb 23, 2023
knwng added a commit to knwng/cpython that referenced this issue May 10, 2023
knwng added a commit to knwng/cpython that referenced this issue May 10, 2023
knwng added a commit to knwng/cpython that referenced this issue May 11, 2023
@arhadthedev arhadthedev added the 3.13 bugs and security fixes label May 11, 2023
knwng added a commit to knwng/cpython that referenced this issue May 11, 2023
knwng added a commit to knwng/cpython that referenced this issue May 13, 2023
@zpz
Copy link

zpz commented Jun 2, 2024

I feel there are alternatives to this feature. After you create a piece of shared memory, you get a proxy to it. If you need any other process to use this piece, just pass this proxy to the other process.

But pickling in multiprocessing.managers has a bug, and the shared_memory part of it is not as friendly as it can be. mpservice.multiprocessing.server_process contains some fixes and enhancements.

I'm thinking of creating a new issue with some bug fixes. I'm researching existing issues in prep for that.

@amitojc
Copy link

amitojc commented Oct 9, 2024

I feel there are alternatives to this feature. After you create a piece of shared memory, you get a proxy to it. If you need any other process to use this piece, just pass this proxy to the other process.

This will run into a problem because apparently, the 'proxy' is an actual file descriptor. So calling "ShareableList" and storing its proxy too many times will run into the OSError: [Errno 24] Too many open files error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes topic-multiprocessing type-feature A feature request or enhancement
Projects
Status: No status
Development

No branches or pull requests

5 participants