You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems calling client.connect() creates a new connection to DBus, and I have to call disconnct() to prevent DBus connection leaking in my program. My program is a daemon process and uses @defer.inlineCallbacks pattern to call dbus method calls.
Not sure it's possible, but it would be convenient if the connection is reused if client.connect() is called multiple times.
The text was updated successfully, but these errors were encountered:
I'm not sure I'd consider that a leak. There are valid use cases for multiple, concurrent DBus connections from the same application but an optional 'reuse_connection=False' argument to the connect() method might not be out of the question. As an interim solution, you may want to opt for creating a single connection in your daemon and simply re-using it rather than creating a fresh connection each time. For example, you could use a method like:
@defer.inlineCallbacks
def getConnection(self):
if self._connection is None:
self._connection = yield self.client.connect()
defer.returnValue(self._connection)
Use that instead of a direct call to client.connect() and you shouldn't have to worry about leaks.
Thanks for the update.. I didn't expect there's valid use cases for multiple DBus connections to the same bus.. :) I did test the same thing with the "python-dbus" binding, and it did reuse the same connection, so I thought it's not common to create a new connection..
I will close this bug, and follow your suggestion.. thanks,
It seems calling
client.connect()
creates a new connection to DBus, and I have to calldisconnct()
to prevent DBus connection leaking in my program. My program is a daemon process and uses@defer.inlineCallbacks
pattern to call dbus method calls.Not sure it's possible, but it would be convenient if the connection is reused if
client.connect()
is called multiple times.The text was updated successfully, but these errors were encountered: