altdesktop / python-dbus-next

🚌 The next great DBus library for Python with asyncio support
https://python-dbus-next.readthedocs.io/en/latest/
MIT License
187 stars 58 forks source link

Cannot close underlying sockets #137

Open yurac opened 1 year ago

yurac commented 1 year ago

I created several instances and got ResourceWarnings as follows: /usr/lib/python3.6/site-packages/dbus_next/introspection.py:172: ResourceWarning: unclosed

Looking into the source code, it seems that there is no place that closes bus underlying sockets. There is the method disconnect() that calls shutdown() but not close(). There is the method _finalize(). However I am not sure how to use these. Close() is never called.

I am currently using the following, which is awkward and not sure if correct: bus.disconnect() bus._finalize() await bus.wait_for_disconnect() bus._sock.close()

Any idea how to correctly close sockets?

elParaguayo commented 1 year ago

From what I can tell, the socket should be closed after shutdown is called. https://stackoverflow.com/a/598759

I can submit a PR for this but I am slightly concerned that this project is dead/dying.