Title: [3.8] bpo-39959: Do not use resource_tracker for shared_memory by rauanargyn · Pull Request #20136 · python/cpython · GitHub
Open Graph Title: [3.8] bpo-39959: Do not use resource_tracker for shared_memory by rauanargyn · Pull Request #20136 · python/cpython
X Title: [3.8] bpo-39959: Do not use resource_tracker for shared_memory by rauanargyn · Pull Request #20136 · python/cpython
Description: This PR aims to fix the issue with "multiprocessing.shared_memory.SharedMemory" class registering open shared memory with resource_tracker, causing shared memory clean up after any of the connecting processes exit. The idea is not to use the resource_tracker at all and let the user be responsible for shared memory clean up. This allows shared memory to persist even if either the creating or any other reading processes have long exited. https://bugs.python.org/issue39959 shm.py from multiprocessing import shared_memory import struct import sys def connect_shm(name): shm_r = shared_memory.SharedMemory(name) print("Attached to shared memory") print(struct.unpack("i", bytes(shm_r.buf[0:4]))) shm_r.close() def create_shm(name, spin=False): shm_c = shared_memory.SharedMemory(name=name, create=True, size=4096*5) print("Created shared memory") buf = shm_c.buf buf[0:4] = struct.pack("i", 4096) shm_c.close() if __name__ == "__main__": mode = sys.argv[1] name = "test" if mode == "-create": create_shm(name, True) elif mode == "-attach": connect_shm(name) python3.8 shm.py -create python3.7 shm.py -attach Before this change resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 1 leaked shared_memory objects to clean up at shutdown After this change Created shared memory Attached to shared memory (4096,) https://bugs.python.org/issue39959
Open Graph Description: This PR aims to fix the issue with "multiprocessing.shared_memory.SharedMemory" class registering open shared memory with resource_tracker, causing shared memory clean up after any of the...
X Description: This PR aims to fix the issue with "multiprocessing.shared_memory.SharedMemory" class registering open shared memory with resource_tracker, causing shared memory clean up after an...
Opengraph URL: https://github.com/python/cpython/pull/20136
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:ac602459-9727-dea3-e13d-1f23a9cf1f13 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E7A4:347197:64FE6E:8A6FFE:6A55A3BE |
| html-safe-nonce | eae3664b23b48ca97394d237ef6f8eee1cdd5a380e51fd23b63da5152013f2a2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFN0E0OjM0NzE5Nzo2NEZFNkU6OEE2RkZFOjZBNTVBM0JFIiwidmlzaXRvcl9pZCI6IjQ2NjU5MTMwMzA2MjYyNzI2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7c0af9d2919c1cc1a045956a0a4098ecd0c51e0f30c2618af3fc84a5b99e10bc |
| hovercard-subject-tag | pull_request:419024171 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/20136/files |
| twitter:image | https://avatars.githubusercontent.com/u/3682260?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/3682260?s=400&v=4 |
| og:image:alt | This PR aims to fix the issue with "multiprocessing.shared_memory.SharedMemory" class registering open shared memory with resource_tracker, causing shared memory clean up after any of the... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 653fccf1e27344851c0d3de3fa6faa526197f072 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width