devices: better handle exceptions in device extension

Do not fail app.save() just because listing devices failed, for any
reason.
This commit is contained in:
Marek Marczykowski-Górecki 2017-07-03 23:08:04 +02:00
parent 77e84b9ce4
commit e5de8f4115
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -241,8 +241,17 @@ class DeviceCollection(object):
attached persistently.
'''
devices = self._vm.fire_event('device-list-attached:' + self._bus,
persistent=persistent)
try:
devices = self._vm.fire_event('device-list-attached:' + self._bus,
persistent=persistent)
except Exception as e: # pylint: disable=broad-except
self._vm.log.exception(e, 'Failed to list {} devices'.format(
self._bus))
if persistent is True:
# don't break app.save()
return self._set
else:
raise
result = set()
for dev, options in devices:
if dev in self._set and not persistent: