xbox360controller icon indicating copy to clipboard operation
xbox360controller copied to clipboard

Disconnecting the Xbox controller raises an exception - possible to handle gracefully and/or pass back to the caller?

Open aaronwoodcox opened this issue 2 years ago • 0 comments

Disconnecting the Xbox controller results in the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/aaron/.local/lib/python3.8/site-packages/xbox360controller/controller.py", line 263, in _event_loop
    event = self.get_event()
  File "/home/aaron/.local/lib/python3.8/site-packages/xbox360controller/controller.py", line 272, in get_event
    buf = self._dev_file.read(8)
OSError: [Errno 19] No such device

It would be really great if a disconnect could be handled more gracefully. Is there a way that the exception could be passed along to the caller so that action could be taken? For example, so the calling application could attempt to reconnect to the controller and/or do something to handle the exception gracefully? Is there any existing mechanism to do so? And if not, would it be possible to add one?

aaronwoodcox avatar Aug 31 '21 05:08 aaronwoodcox