aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-01-21 13:00:27 +0100
committerAnton Khirnov <anton@khirnov.net>2023-01-21 13:00:27 +0100
commit2247eb7d9031f467efe82da735a96319ffa23a35 (patch)
tree1e800e96ab39a036923c6952edd9d409d081c92c
parent7be242fb7f9909c50840e43afea154b4ada966fc (diff)
uinput_mng: handle OSError in PhysDevices.remove()
Erasing effects might raise OSError if the device was already unplugged.
-rwxr-xr-xuinput_mng17
1 files changed, 12 insertions, 5 deletions
diff --git a/uinput_mng b/uinput_mng
index 5d68908..65797fb 100755
--- a/uinput_mng
+++ b/uinput_mng
@@ -221,14 +221,21 @@ class PhysDevices(dict):
self._logger.info('Removing: %s', str(d))
- # erase any uploaded FF effects
- for did in self._ff_effect_idmap[path].values():
- d.erase_effect(did)
- del self._ff_effect_idmap[path]
-
self._sel.unregister(d)
+
+ # the following might fail if the device has been unplugged
+ try:
+ # erase any uploaded FF effects
+ for did in self._ff_effect_idmap[path].values():
+ d.erase_effect(did)
+
+ except OSError as e:
+ self._logger.error('Error unloading device "%s": %s',
+ path, os.strerror(e.errno))
d.close()
+ del self._ff_effect_idmap[path]
+
def upload_effect(self, effect):
# upload the effect to all currently tracked devices
for name, d in self.items():