chrippa/ds4drv

Clean exit on SIGINT?

Opened this issue · 4 comments

Hi guys,

Love the work you've done with this - works perfectly on my Ubuntu machine! Would you guys be interested in a PR that exited cleanly (i.e, without a stack trace) on a SIGINT in an active terminal? This gets a bit cumbersome when I'm running it:

^CTraceback (most recent call last):
  File "/usr/local/bin/ds4drv", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/ds4drv/__main__.py", line 154, in main
    for device in backend.devices:
  File "/usr/local/lib/python2.7/dist-packages/ds4drv/backends/hidraw.py", line 148, in devices
    for hidraw_device in itertools.chain(existing_devices, future_devices):
  File "/usr/local/lib/python2.7/dist-packages/ds4drv/backends/hidraw.py", line 127, in _get_future_devices
    for device in iter(monitor.poll, None):
  File "/usr/local/lib/python2.7/dist-packages/pyudev/monitor.py", line 357, in poll
    if eintr_retry_call(poll.Poll.for_events((self, 'r')).poll, timeout):
  File "/usr/local/lib/python2.7/dist-packages/pyudev/_util.py", line 163, in eintr_retry_call
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyudev/_os/poll.py", line 97, in poll
    return list(self._parse_events(eintr_retry_call(self._notifier.poll, timeout)))
  File "/usr/local/lib/python2.7/dist-packages/pyudev/_util.py", line 163, in eintr_retry_call
    return func(*args, **kwargs)
KeyboardInterrupt

Cheers!

Ape commented

This should already work correctly. Here's an example output for me:

[info][controller 1] Created devices /dev/input/js0 (joystick) /dev/input/event19 (evdev) 
[info][controller 1] Connected to Bluetooth Controller (1C:66:6D:1A:6F:A0 hidraw2)
[info][hidraw] Scanning for devices
[info][controller 1] Battery: Fully charged
^C[info][controller 1] Disconnected
[info][controller 1] Cleaning up...
Ape commented

Does this only occur rarely for you? Can you try if Python 3 changes anything?

I'll give Python 3 a try out - it occurs every time I close

Same here with Arch Linux and Python 3.7.3!