Title: Python 3.12+ breaks backwards compatibility for logging QueueHandler with some Queue classes · Issue #119819 · python/cpython · GitHub
Open Graph Title: Python 3.12+ breaks backwards compatibility for logging QueueHandler with some Queue classes · Issue #119819 · python/cpython
X Title: Python 3.12+ breaks backwards compatibility for logging QueueHandler with some Queue classes · Issue #119819 · python/cpython
Description: Bug report Bug description: Related bug: #111615 Related pull: #111638 Related codes: cpython/Lib/logging/config.py Lines 789 to 804 in bd0d97c if 'queue' in config: from multiprocessing.queues import Queue as MPQueue qspec = config['que...
Open Graph Description: Bug report Bug description: Related bug: #111615 Related pull: #111638 Related codes: cpython/Lib/logging/config.py Lines 789 to 804 in bd0d97c if 'queue' in config: from multiprocessing.queues imp...
X Description: Bug report Bug description: Related bug: #111615 Related pull: #111638 Related codes: cpython/Lib/logging/config.py Lines 789 to 804 in bd0d97c if 'queue' in config: from multiprocessing.qu...
Opengraph URL: https://github.com/python/cpython/issues/119819
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Python 3.12+ breaks backwards compatibility for logging QueueHandler with some Queue classes","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\nRelated bug: https://github.com/python/cpython/issues/111615\r\nRelated pull: https://github.com/python/cpython/pull/111638\r\nRelated [codes](https://github.com/python/cpython/blob/3.12/Lib/logging/config.py#L789-L804):\r\nhttps://github.com/python/cpython/blob/bd0d97ce3497da35d17daa329c294f4cb87196ee/Lib/logging/config.py#L789-L804\r\n\r\n#### reproducible example using Python 3.12.3\r\n\r\n```python\r\nimport logging.config\r\n\r\n\r\ndef main(q):\r\n config = {\r\n 'version': 1,\r\n 'handlers': {\r\n 'sink': {\r\n 'class': 'logging.handlers.QueueHandler',\r\n 'queue': q,\r\n },\r\n },\r\n 'root': {\r\n 'handlers': ['sink'],\r\n },\r\n }\r\n logging.config.dictConfig(config)\r\n\r\n\r\nif __name__ == '__main__':\r\n import multiprocessing as mp\r\n main(mp.Manager().Queue())\r\n #import asyncio\r\n #main(asyncio.Queue()) # broken too\r\n```\r\n\r\nerror:\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"/usr/lib/python3.12/logging/config.py\", line 581, in configure\r\n handler = self.configure_handler(handlers[name])\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/usr/lib/python3.12/logging/config.py\", line 801, in configure_handler\r\n raise TypeError('Invalid queue specifier %r' % qspec)\r\nTypeError: Invalid queue specifier \u003cAutoProxy[Queue] object, typeid 'Queue' at 0x7f8b07189d90\u003e\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nTraceback (most recent call last):\r\n File \"/home/xxx/logging-queue-handler-bug.py\", line 33, in \u003cmodule\u003e\r\n main(mp.Manager().Queue())\r\n File \"/home/xxx/logging-queue-handler-bug.py\", line 29, in main\r\n logging.config.dictConfig(config)\r\n File \"/usr/lib/python3.12/logging/config.py\", line 914, in dictConfig\r\n dictConfigClass(config).configure()\r\n File \"/usr/lib/python3.12/logging/config.py\", line 588, in configure\r\n raise ValueError('Unable to configure handler '\r\nValueError: Unable to configure handler 'sink'\r\n```\r\n\r\n#### Queue classes to check for logging QueueHandler\r\n\r\n* queue.Queue(), `\u003cqueue.Queue at 0x7fb86eeef170\u003e`, **works**.\r\n* multiprocessing\r\n - multiprocessing.Queue(), `\u003cmultiprocessing.queues.Queue at 0x7fb871790500\u003e`, **works**.\r\n - multiprocessing.Manager().Queue() `\u003cAutoProxy[Queue] object, typeid 'Queue' at 0x7fb86ef4a840\u003e`, **broken**.\r\n Its class is `multiprocessing.managers.AutoProxy[Queue]`, a subclass of `multiprocessing.managers.BaseProxy`.\r\n* asyncio.queues.Queue() `\u003cQueue at 0x7fb86f0be4e0 maxsize=0\u003e`, **broken**.\r\n* any other Queue?\r\n\r\n#### discuss: how to fix\r\n\r\nCheck all Queue classes mentioned above in\r\nhttps://github.com/python/cpython/blob/bd0d97ce3497da35d17daa329c294f4cb87196ee/Lib/logging/config.py#L792\r\n\r\nor just focus on handling special cases: str and dict, while leaving other cases un-checked (e.g., queue.Queue, multiprocessing.queues.Queue).\r\n\r\n\r\n### CPython versions tested on:\r\n\r\n3.12\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-120030\n* gh-120034\n* gh-120035\n* gh-120067\n* gh-120071\n* gh-120072\n* gh-120090\n* gh-120092\n* gh-120093\n* gh-120476\n* gh-120531\n* gh-120532\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/shmilee","@type":"Person","name":"shmilee"},"datePublished":"2024-05-31T05:02:48.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":20},"url":"https://github.com/119819/cpython/issues/119819"}
| 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:bdbbb802-a09c-9549-724a-fd3449d9624e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DD54:AA16D:EFBD34:14F3076:696A33D5 |
| html-safe-nonce | 136ae87db678ac55d9bbcc37b2c35c717861badad1a33a6c889a42e652a969e8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERDU0OkFBMTZEOkVGQkQzNDoxNEYzMDc2OjY5NkEzM0Q1IiwidmlzaXRvcl9pZCI6IjM4NzgxOTU1MTI1ODk1NjI4MzciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 6dbeee49042b4899fcac58b2589b60441aa01dcd0d5a6f4eb667ee8125992226 |
| hovercard-subject-tag | issue:2326968325 |
| 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/119819/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a721900b5b4e728964799f71a186f881e8b8fd96ad4a7916ee49cc23bb13626a/python/cpython/issues/119819 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a721900b5b4e728964799f71a186f881e8b8fd96ad4a7916ee49cc23bb13626a/python/cpython/issues/119819 |
| og:image:alt | Bug report Bug description: Related bug: #111615 Related pull: #111638 Related codes: cpython/Lib/logging/config.py Lines 789 to 804 in bd0d97c if 'queue' in config: from multiprocessing.queues imp... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | shmilee |
| hostname | github.com |
| expected-hostname | github.com |
| None | 321736bfdb3f591415ae895a0459bec204b26a76caf47ba5c980634cfacc4538 |
| 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 | 7a9163cefd1ea4bd06f8eb7c082f43e4e53f626f |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width