Inconsistent behaviour of multiprocessing.shared_memory
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 36k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
An example code already exists in the documentation (see from here: The following example demonstrates a practical use of the SharedMemory class with NumPy arrays, accessing the same numpy.ndarray from two distinct Python shells).
The code executes fine as expected and mentioned there until one closes the terminals which report warnings.
When the second terminal is closed: /home/souradeep/miniconda/envs/py39/lib/python3.9/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked shared_memory objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d '
and when the first terminal is closed: /home/souradeep/miniconda/envs/py39/lib/python3.9/multiprocessing/resource_tracker.py:229: UserWarning: resource_tracker: '/trial': [Errno 2] No such file or directory: '/trial'
This can have implications when one tries to use the feature somewhere in an application (see an example).
CPython versions tested on:
3.9
Operating systems tested on:
Linux
Linked PRs
- gh-119126
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the shared-memory example in the multiprocessing documentation and inspect multiprocessing/resource_tracker.py, focusing on the shutdown warnings reproduced in the report. Review linked PR gh-119126 and its tests, if available; the issue is done when the documented example no longer produces the reported resource-tracker warnings on shutdown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100