Title: AttributeError: BadRRModeError object has no attribute 'sequence_number' · Issue #259 · python-xlib/python-xlib · GitHub
Open Graph Title: AttributeError: BadRRModeError object has no attribute 'sequence_number' · Issue #259 · python-xlib/python-xlib
X Title: AttributeError: BadRRModeError object has no attribute 'sequence_number' · Issue #259 · python-xlib/python-xlib
Description: Dear maintainer, tldr; An uncaught exception in parse_error_response() causes the next call to get_input_focus() to hang indefinitely with 100% CPU usage. Details OS: Debian Bookworm Python version: 3.10.9 python3-xlib version: 0.33-1 Th...
Open Graph Description: Dear maintainer, tldr; An uncaught exception in parse_error_response() causes the next call to get_input_focus() to hang indefinitely with 100% CPU usage. Details OS: Debian Bookworm Python version...
X Description: Dear maintainer, tldr; An uncaught exception in parse_error_response() causes the next call to get_input_focus() to hang indefinitely with 100% CPU usage. Details OS: Debian Bookworm Python version...
Opengraph URL: https://github.com/python-xlib/python-xlib/issues/259
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AttributeError: BadRRModeError object has no attribute 'sequence_number'","articleBody":"Dear maintainer,\r\n\r\n**tldr**; An uncaught exception in `parse_error_response()` causes the next call to `get_input_focus()` to hang indefinitely with 100% CPU usage.\r\n\r\n## Details\r\n\r\n**OS**: Debian Bookworm\r\n**Python version**: 3.10.9\r\n**python3-xlib version**: 0.33-1\r\n\r\nThe application I use calls `win.get_full_property(self._NET_WM_NAME, 0)` where `win` is instance of `Window` from `drawable.py` and `self._NET_WM_NAME` is 326.\r\n\r\nThe traceback is as follows:\r\n\r\n```\r\nTraceback (most recent call last):\r\n File \"/usr/bin/keyd-application-mapper\", line 156, in get_title\r\n x = win.get_full_property(self._NET_WM_NAME, 0).value\r\n File \"/usr/lib/python3/dist-packages/Xlib/xobject/drawable.py\", line 476, in get_full_property\r\n prop = self.get_property(property, property_type, sizehint,\r\n File \"/usr/lib/python3/dist-packages/Xlib/xobject/drawable.py\", line 455, in get_property\r\n r = request.GetProperty(display = self.display,\r\n File \"/usr/lib/python3/dist-packages/Xlib/protocol/rq.py\", line 1368, in __init__\r\n self.reply()\r\n File \"/usr/lib/python3/dist-packages/Xlib/protocol/rq.py\", line 1380, in reply\r\n self._display.send_and_recv(request = self._serial)\r\n File \"/usr/lib/python3/dist-packages/Xlib/protocol/display.py\", line 612, in send_and_recv\r\n gotreq = self.parse_response(request)\r\n File \"/usr/lib/python3/dist-packages/Xlib/protocol/display.py\", line 719, in parse_response\r\n gotreq = self.parse_error_response(request) or gotreq\r\n File \"/usr/lib/python3/dist-packages/Xlib/protocol/display.py\", line 745, in parse_error_response\r\n req = self.get_waiting_request(e.sequence_number)\r\nAttributeError: 'BadRRModeError' object has no attribute 'sequence_number'\r\n```\r\n\r\nThe [`BadRRModeError`](https://github.com/python-xlib/python-xlib/commit/c87624dd6ec780417e2d32529976d65fed344045) exception was added by `disp.extension_add_error(BadRRMode, BadRRModeError)` in `Xlib/ext/randr.py` and seems to be quite different from the other errors defined in `Xlib/error.py` and in particular the '**sequence_number**' attribute does not exist.\r\n\r\nThe application I use logs this error and proceeds by calling `dpy.next_event()` and then `dpy.dpy.get_input_focus()` where `dpy = Xlib.display.Display()`.\r\n\r\n_The last call hangs indefinitely with 100% CPU usage and seems to do so because of the previous_ `BadRRModeError`.\r\n\r\nI used Python's [faulthandler](https://docs.python.org/3/library/faulthandler.html) module to investigate where the code hangs (i.e. `python3 -X faulthandler application.py` and then sending `SIGARBT` to see where the main thread is). I did this several times and every time the thread was busy inside the `send_and_recv()` function in `Xlib/protocol/display.py`:\r\n```\r\nCurrent thread 0x00007f30fc5fe040 (most recent call first):\r\n File \"/usr/lib/python3/dist-packages/Xlib/protocol/display.py\", line 515 in send_and_recv\r\n File \"/usr/lib/python3/dist-packages/Xlib/protocol/rq.py\", line 1380 in reply\r\n File \"/usr/lib/python3/dist-packages/Xlib/protocol/rq.py\", line 1368 in __init__\r\n File \"/usr/lib/python3/dist-packages/Xlib/display.py\", line 607 in get_input_focus\r\n File \"/usr/bin/keyd-application-mapper\", line 200 in run\r\n File \"/usr/bin/keyd-application-mapper\", line 419 in \u003cmodule\u003e\r\n```\r\n\r\n## Workaround\r\n\r\nI'm not very familiar with python-xlib internals, so I still don't fully understand what is going on.\r\n\r\nA temporary solution for my case is to simply remove the line `disp.extension_add_error(BadRRMode, BadRRModeError)` which instead causes the error to appear as:\r\n```\r\nTraceback (most recent call last):\r\n File \"/usr/bin/keyd-application-mapper\", line 174, in get_window_info\r\n return (cls[1], get_title(win))\r\n File \"/usr/bin/keyd-application-mapper\", line 155, in get_title\r\n raise err from None\r\n File \"/usr/bin/keyd-application-mapper\", line 153, in get_title\r\n title = win.get_full_property(self._NET_WM_NAME, 0).value.decode('utf8')\r\n File \"/usr/lib/python3/dist-packages/Xlib/xobject/drawable.py\", line 476, in get_full_property\r\n prop = self.get_property(property, property_type, sizehint,\r\n File \"/usr/lib/python3/dist-packages/Xlib/xobject/drawable.py\", line 455, in get_property\r\n r = request.GetProperty(display = self.display,\r\n File \"/usr/lib/python3/dist-packages/Xlib/protocol/rq.py\", line 1368, in __init__\r\n self.reply()\r\n File \"/usr/lib/python3/dist-packages/Xlib/protocol/rq.py\", line 1388, in reply\r\n raise self._error\r\nXlib.error.BadValue: \u003cclass 'Xlib.error.BadValue'\u003e: code = 2, resource_id = 10, sequence_number = 4818, major_opcode = 20, minor_opcode = 0\r\n```\r\nwhich does not cause `get_input_focus()` to hang.\r\n\r\n","author":{"url":"https://github.com/Penlect","@type":"Person","name":"Penlect"},"datePublished":"2023-01-13T18:03:10.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/259/python-xlib/issues/259"}
| 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:7f1a77c3-bd55-4bde-affb-e68477a14299 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D24C:9124A:82FC07:A9DCD4:696AED74 |
| html-safe-nonce | 83da185517bd534e236821b707a131ddfd5697d2d044f9f2cf27a536d164842f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjRDOjkxMjRBOjgyRkMwNzpBOURDRDQ6Njk2QUVENzQiLCJ2aXNpdG9yX2lkIjoiNDk2MjM4NTMyNTU3MzQ2NzUwOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 34595cbbe472cdf9f93ab7e466d08277d614e2b2cc07c19eca721708c3cd7bbc |
| hovercard-subject-tag | issue:1532708686 |
| 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-xlib/python-xlib/259/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8f511578b2290facd4074b5d203e2c8122517f8a1f5c8aa99a2e7213c4b76a2f/python-xlib/python-xlib/issues/259 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8f511578b2290facd4074b5d203e2c8122517f8a1f5c8aa99a2e7213c4b76a2f/python-xlib/python-xlib/issues/259 |
| og:image:alt | Dear maintainer, tldr; An uncaught exception in parse_error_response() causes the next call to get_input_focus() to hang indefinitely with 100% CPU usage. Details OS: Debian Bookworm Python version... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Penlect |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python-xlib/python-xlib git https://github.com/python-xlib/python-xlib.git |
| octolytics-dimension-user_id | 16151530 |
| octolytics-dimension-user_login | python-xlib |
| octolytics-dimension-repository_id | 47391866 |
| octolytics-dimension-repository_nwo | python-xlib/python-xlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 47391866 |
| octolytics-dimension-repository_network_root_nwo | python-xlib/python-xlib |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width