Skip to content

uinput listener.wait() hangs, missing self._mark_ready() in _run #685

Description

@KirkSuD

Description

uinput listener.wait() gets stuck in this while loop:

def wait(self):
"""Waits for this listener to become ready."""
self._condition.acquire()
while not self._ready:
self._condition.wait()
self._condition.release()

self._mark_ready() is missing in _run:

def _run(self):
for event in self._dev.read_loop():
if event.type in self._EVENTS:
self._handle_message(event)

The listener still works, but listener.wait() or with listener: hangs when using uinput backend.

Platform and pynput version
OS: Fedora Linux 44
Desktop: GNOME 50 (Wayland)
pynput version: 1.8.2

To Reproduce

import os
os.environ["PYNPUT_BACKEND_KEYBOARD"] = "uinput"

from pynput import keyboard

def on_activate_h():
    print('<ctrl>+<alt>+h pressed')

with keyboard.GlobalHotKeys({
        '<ctrl>+<alt>+h': on_activate_h}) as h:
    print("hello")  # never printed
    h.join()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions