Calling InputDevice.read() or InputDevice.read_one() on a file that was deleted (such as removing the USB device) was causing a hang for me (notice the KeyboardInterrupt after the OSError, my code has no threading or exception handling):
Traceback (most recent call last):
File "/home/stevarino/mpv/x11.py", line 78, in <module>
main()
File "/home/stevarino/mpv/x11.py", line 19, in main
run(dev)
File "/home/stevarino/mpv/x11.py", line 28, in run
event: InputEvent = dev.read_one()
^^^^^^^^^^^^^^
File "/home/stevarino/mpv/env/lib/python3.11/site-packages/evdev/eventio.py", line 58, in read_one
event = _input.device_read(self.fd)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 19] No such device
^CException ignored in: <module 'threading' from '/usr/lib/python3.11/threading.py'>
Traceback (most recent call last):
File "/usr/lib/python3.11/threading.py", line 1583, in _shutdown
lock.acquire()
KeyboardInterrupt:
I forked and built the source fairly easy and began debugging why this is happening, inspecting the read call errno, adding fprintf calls, and I noticed that it had stopped hanging immediately after installing my locally built version.
OS details:
(env) stevarino@pi-hub:~/mpv $ raspinfo
System Information
------------------
Raspberry Pi 3 Model B Rev 1.2
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
Raspberry Pi reference 2025-05-13
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 5dabc7dc940059dfbc46af5d97b60a1e812523dd, stage4
Linux pi-hub 6.12.75+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.75-1+rpt1~bookworm (2026-03-11) aarch64 GNU/Linux
[...]
I'm unsure how to go about troubleshooting this but if you need any further details or tests please let me know.
Calling
InputDevice.read()orInputDevice.read_one()on a file that was deleted (such as removing the USB device) was causing a hang for me (notice the KeyboardInterrupt after the OSError, my code has no threading or exception handling):I forked and built the source fairly easy and began debugging why this is happening, inspecting the read call
errno, addingfprintfcalls, and I noticed that it had stopped hanging immediately after installing my locally built version.OS details:
I'm unsure how to go about troubleshooting this but if you need any further details or tests please let me know.