Skip to content

Commit 37097fb

Browse files
committed
Merge remote-tracking branch 'origin/pr/402'
* origin/pr/402: Deserialize device in events only if there is a handler registered
2 parents 28b79d7 + 322aa48 commit 37097fb

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

qubesadmin/events/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@ def handle(self, subject, event, **kwargs):
264264
except KeyError:
265265
pass
266266

267+
handlers = [h_func for h_name, h_func_set in self.handlers.items()
268+
for h_func in h_func_set
269+
if fnmatch.fnmatch(event, h_name)]
270+
271+
# skip deserializing parameters (which may make further Admin API calls)
272+
# if no handler is registered for the event
273+
if not handlers:
274+
return
275+
267276
# deserialize known attributes
268277
if event.startswith('device-'):
269278
try:
@@ -292,9 +301,6 @@ def handle(self, subject, event, **kwargs):
292301
except (KeyError, ValueError):
293302
pass
294303

295-
handlers = [h_func for h_name, h_func_set in self.handlers.items()
296-
for h_func in h_func_set
297-
if fnmatch.fnmatch(event, h_name)]
298304
for handler in handlers:
299305
try:
300306
handler(subject, event, **kwargs)

0 commit comments

Comments
 (0)