Title: Update logging library module lock to use context manager to acquire/release lock. · Issue #109461 · python/cpython · GitHub
Open Graph Title: Update logging library module lock to use context manager to acquire/release lock. · Issue #109461 · python/cpython
X Title: Update logging library module lock to use context manager to acquire/release lock. · Issue #109461 · python/cpython
Description: Feature or enhancement Proposal: Current implementation relies on both _acquireLock() and _releaseLock() being called, otherwise a lock may never be released: def _acquireLock(): """ Acquire the module-level lock for serializing access t...
Open Graph Description: Feature or enhancement Proposal: Current implementation relies on both _acquireLock() and _releaseLock() being called, otherwise a lock may never be released: def _acquireLock(): """ Acquire the mo...
X Description: Feature or enhancement Proposal: Current implementation relies on both _acquireLock() and _releaseLock() being called, otherwise a lock may never be released: def _acquireLock(): """...
Opengraph URL: https://github.com/python/cpython/issues/109461
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Update logging library module lock to use context manager to acquire/release lock.","articleBody":"# Feature or enhancement\n\n### Proposal:\n\n\nCurrent implementation relies on both `_acquireLock()` and `_releaseLock()` being called, otherwise a lock may never be released:\n\n```python\ndef _acquireLock():\n \"\"\"\n Acquire the module-level lock for serializing access to shared data.\n\n This should be released with _releaseLock().\n \"\"\"\n if _lock:\n try:\n _lock.acquire()\n except BaseException:\n _lock.release()\n raise\n\ndef _releaseLock():\n \"\"\"\n Release the module-level lock acquired by calling _acquireLock().\n \"\"\"\n if _lock:\n _lock.release()\n```\nThe majority of usages of `_acquireLock()` manually add a try/except/finally block to ensure that the lock is released if an exception is thrown. Some usages of `_acquireLock()` have no safety.\n\nThe proposal is to alter the usage of `_acquireLock()` to be a context manager that deals with acquiring and releasing automatically rather than requiring try/except/finally blocks to be used anywhere the function is called. \n\nFor example,\nusage before:\n```python\n_acquireLock()\ntry:\n ...\nfinally:\n _releaseLock()\n```\nproposed usage:\n```python\nwith _acquireLock():\n ...\n```\n\n\n\n### Has this already been discussed elsewhere?\n\nThis is a minor feature, which does not need previous discussion elsewhere\n\n### Links to previous discussion of this feature:\n\n_No response_\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-109462\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/dcollison","@type":"Person","name":"dcollison"},"datePublished":"2023-09-15T17:06:25.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/109461/cpython/issues/109461"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7de82ce3-e12f-8fda-fad7-f3666aad3038 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8434:1171B:AE2C31:EA2FCB:6A4D7584 |
| html-safe-nonce | a51516c53b45d9c536542232065e56d4619117e8e4498f92235aecc53466cafc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NDM0OjExNzFCOkFFMkMzMTpFQTJGQ0I6NkE0RDc1ODQiLCJ2aXNpdG9yX2lkIjoiNjE0MjUzODIxMTM0MTk4OTI1MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cfa7aa59786c1ee41cf332da8765e9f929d755d96aa26a92e5064ea146ce3e49 |
| hovercard-subject-tag | issue:1898794460 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/109461/issue_layout |
| twitter:image | https://opengraph.githubassets.com/863c9bf90b36bfc79afbdb520dbdb3194b9cc64ca535eca03326137f06dfd1fa/python/cpython/issues/109461 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/863c9bf90b36bfc79afbdb520dbdb3194b9cc64ca535eca03326137f06dfd1fa/python/cpython/issues/109461 |
| og:image:alt | Feature or enhancement Proposal: Current implementation relies on both _acquireLock() and _releaseLock() being called, otherwise a lock may never be released: def _acquireLock(): """ Acquire the mo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dcollison |
| hostname | github.com |
| expected-hostname | github.com |
| None | c78260c7b3f4ac4b0356c8208537f05406a3a2d46a9ec3f735b372dcc519c39e |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 399fff412f48461d435721c009efc17ea44be72f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width