_closed_callback function causes traces

Issue #14 new
Christian Schwamborn created an issue

I don’t know exactly if this is an actual issue of pynotify2 of a new wired behaviour of my dbus (debian bullseye). The first calls (and callbacks aswell) work as expected, then KeyError exceptions from function _closed_callback start to show up.

After placing some debug lines, i realized, that those callbacks causing the exeptions are actually not from ‘my own’ notifications, but from other ones randomly showing up. So when these signals come in, there is naturally no key in the registry.

I don’t know if we should get signals for all callbacks, or just the ones for the notifications we created ourself. If this dbus behaviour is correct, these exception should be caught and ignored.

 def _closed_callback(nid, reason):
     nid, reason = int(nid), int(reason)
+    try:
-    n = notifications_registry[nid]
+        n = notifications_registry[nid]
+    except KeyError:
+        return
     n._closed_callback(n)
     del notifications_registry[nid]

The same is probably true for the action_callback above, as the other callbacks i got, didn’t had callbacks, nothing happend there, but I imagine, that the same issue might be preset there aswell.

Comments (1)

  1. Log in to comment