Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I am getting: 2024-04-06 13:38:10,669 ERROR libqtile core.py:_xpoll():L372 Got an exception in poll loop Traceback (most recent call last): File "/home/tycho/.local/lib/python3.11/site-packages/libqtile/backend/x11/core.py", line 347, in _xpoll self.handle_event(event) File "/home/tycho/.local/lib/python3.11/site-packages/libqtile/backend/x11/core.py", line 314, in handle_event ret = target(event) ^^^^^^^^^^^^^ File "/home/tycho/.local/lib/python3.11/site-packages/libqtile/backend/x11/core.py", line 663, in handle_KeyPress key, handled = self.qtile.process_key_event(keysym, event.state & self._valid_mask) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/tycho/.local/lib/python3.11/site-packages/libqtile/core/manager.py", line 449, in process_key_event if cmd.check(self): ^^^^^^^^^^^^^^^ File "/home/tycho/.local/lib/python3.11/site-packages/libqtile/lazy.py", line 148, in check cur_win_floating = q.current_window and q.current_window.floating ^^^^^^^^^^^^^^^^ File "/home/tycho/.local/lib/python3.11/site-packages/libqtile/command/base.py", line 281, in __getattr__ raise AttributeError(f"{self.__class__} has no attribute {name}") AttributeError: <class 'libqtile.core.manager.Qtile'> has no attribute current_window on restart. current_screen is first set in: loop -> async_loop -> load_config() -> _process_screens() but in async_loop(), we setup_listener() before we load the config, i.e.: loop -> async_loop -> setup_listener() # whoops ... -> load_config() -> _process_screens() This means that we could potentially race and start receiving events before we were completely configured, as above. This is especially likely if we are restarting, but the race exists as well on startup and could be present if e.g. people were starting things in their xsessions before exec()ing qtile. To fix this, we load the config before we setup the listener, so that everything will be present. But there's a bit of a circular dependency we need to break here: setup_listener() is the one that initialize's the Core's copy of the qtile object. Let's just set that explicitly in Core's async_loop(), and remove the parameter of setup_listener(). So then we have: 1. initialize qtile object 2. load_config() 3. setup_listener() and hopefully we won't see more races like this. Indeed, what clued me in that it was a race vs just a bug is that I saw other missing attributes sometimes on restarts e.g.: AttributeError: <class 'libqtile.backend.x11.window.Window'> has no attribute has_focus This is an interesting bug: it seems like it has been around for quite a long time, but perhaps the new asyncio and python speed improvements are making it such that now we can actually see it? Fixes #4755 Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
- Loading branch information