ldo / dbussy

Python binding for D-Bus using asyncio
91 stars 22 forks source link

ravel.Connection.__del__ doesn't reference interfaces as a dict yet #19

Closed joell closed 5 years ago

joell commented 5 years ago

The Connection.__del__ method seems to expect interfaces to be an iterable of objects. However, it appears that interfaces is now a string-indexed dictionary of objects, as other portions of the code indicate.

Currently, I get the following error when starting a Ravel server.[1]

Exception ignored in: <function Connection.__del__ at 0x7ff20c5e2e60>
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/ravel.py", line 258, in __del__
    remove_listeners(self._dispatch, [])
  File "/usr/lib/python3.7/site-packages/ravel.py", line 237, in remove_listeners
    remove_listeners(child, path + [node])
  File "/usr/lib/python3.7/site-packages/ravel.py", line 237, in remove_listeners
    remove_listeners(child, path + [node])
  File "/usr/lib/python3.7/site-packages/ravel.py", line 237, in remove_listeners
    remove_listeners(child, path + [node])
  File "/usr/lib/python3.7/site-packages/ravel.py", line 240, in remove_listeners
    for rulestr in interface.listening :
AttributeError: 'str' object has no attribute 'listening'

This error goes away when I apply the following change that iterates over the interfaces values instead of (implicty) over the string keys of the interfaces dictionary:

--- a/ravel.py
+++ b/ravel.py
@@ -236,7 +236,7 @@ class Connection(dbus.TaskKeeper) :
             for node, child in level.children.items() :
                 remove_listeners(child, path + [node])
             #end for
-            for interface in level.interfaces :
+            for interface in level.interfaces.values() :
                 for rulestr in interface.listening :
                     ignore = dbus.Error.init()
                     self.connection.bus_remove_match(rulestr, ignore)

[1] Yes, the Connection is deleted when I start the Ravel service. I still haven't tracked down why the connection is getting closed almost immediately on startup, but that will be another issue.

ldo commented 5 years ago

Done in ae8b2c622d5c91c1e3bc91cee1e960d518d7a921.