boppreh / keyboard

Hook and simulate global keyboard events on Windows and Linux.
MIT License
3.8k stars 433 forks source link

OSError: [Errno 19] No such device (different from issue #397) #531

Closed Chris-Calvo closed 2 years ago

Chris-Calvo commented 2 years ago

Hello, I am running into an issue where if my keyboard disconnects, events on the keyboard are no longer listed to, even if the keyboard reconnects. Here is the full traceback error:

` Exception in thread Thread-4: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner

Exception in thread Thread-6: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner Exception in thread Thread-5: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 892, in run self.run() File "/usr/lib/python3.9/threading.py", line 892, in run self.run() File "/usr/lib/python3.9/threading.py", line 892, in run self._target(*self._args, self._kwargs) File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 106, in start_reading self.event_queue.put(device.read_event()) self._target(*self._args, *self._kwargs) File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 106, in start_reading self.event_queue.put(device.read_event()) self._target(self._args, self._kwargs) File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 106, in start_reading self.event_queue.put(device.read_event()) File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 83, in read_event data = self.input_file.read(struct.calcsize(event_bin_format))

OSError: [Errno 19] No such device File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 83, in read_event File "/usr/local/lib/python3.9/dist-packages/keyboard/_nixcommon.py", line 83, in read_event data = self.input_file.read(struct.calcsize(event_bin_format))

OSError: [Errno 19] No such device data = self.input_file.read(struct.calcsize(event_bin_format)) OSError: [Errno 19] No such device Traceback (most recent call last): File "/home/pi/Documents/URaspServer.py", line 149, in elif(keyboard.is_pressed('4')) File "/usr/local/lib/python3.9/dist-packages/keyboard/init.py", line 417, in is_pressed steps = parse_hotkey(hotkey) File "/usr/local/lib/python3.9/dist-packages/keyboard/init.py", line 344, in parse_hotkey scan_codes = key_to_scan_codes(hotkey) File "/usr/local/lib/python3.9/dist-packages/keyboard/init.py", line 317, in key_to_scan_codes t = tuple(_collections.OrderedDict((scan_code, True) for scan_code, modifier in _os_keyboard.map_name(normalized))) File "/usr/local/lib/python3.9/dist-packages/keyboard/init.py", line 317, in t = tuple(_collections.OrderedDict((scan_code, True) for scan_code, modifier in _os_keyboard.map_name(normalized))) KeyboardInterrupt `

I know this is one of those "plz help fix for me" posts, so I apologize and I understand that there are hundreds of other issues open on your page as of now. The only issue was similar was issue I saw was #397 (Fix #436), but this appears to be happening in a different location.

Chris-Calvo commented 2 years ago

Just realized this is THE SAME as issue #397, I just needed to step away and come back with some fresh eyes I guess