diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-01-21 13:00:27 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-01-21 13:00:27 +0100 |
commit | 2247eb7d9031f467efe82da735a96319ffa23a35 (patch) | |
tree | 1e800e96ab39a036923c6952edd9d409d081c92c | |
parent | 7be242fb7f9909c50840e43afea154b4ada966fc (diff) |
uinput_mng: handle OSError in PhysDevices.remove()
Erasing effects might raise OSError if the device was already unplugged.
-rwxr-xr-x | uinput_mng | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -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(): |