Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot close underlying sockets #137

Open
yurac opened this issue Oct 28, 2022 · 1 comment · May be fixed by #148
Open

Cannot close underlying sockets #137

yurac opened this issue Oct 28, 2022 · 1 comment · May be fixed by #148

Comments

@yurac
Copy link

yurac commented Oct 28, 2022

I created several instances and got ResourceWarnings as follows:
/usr/lib/python3.6/site-packages/dbus_next/introspection.py:172: ResourceWarning: unclosed <socket.socket fd=26, family=AddressFamily.AF_UNIX, type=2049, proto=0, raddr=/run/dbus/system_bus_socket>

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?

@yurac yurac changed the title Cannot close underlying fds Cannot close underlying sockets Oct 28, 2022
@elParaguayo
Copy link
Contributor

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.

elParaguayo added a commit to elParaguayo/python-dbus-next that referenced this issue Jan 7, 2023
As per issue altdesktop#137, sockets are not closed when the bus is disconnected.
This results in users receiving warnings about unclosed sockets.

This PR adds a call to the socket's `close` method during `disconnect`.

Closes altdesktop#137
@elParaguayo elParaguayo linked a pull request Jan 7, 2023 that will close this issue
garyvdm pushed a commit to garyvdm/dbus-ezy that referenced this issue May 9, 2024
As per issue altdesktop#137, sockets are not closed when the bus is disconnected.
This results in users receiving warnings about unclosed sockets.

This PR adds a call to the socket's `close` method during `disconnect`.

Closes altdesktop#137
garyvdm pushed a commit to garyvdm/dbus-ezy that referenced this issue May 10, 2024
As per issue altdesktop#137, sockets are not closed when the bus is disconnected.
This results in users receiving warnings about unclosed sockets.

This PR adds a call to the socket's `close` method during `disconnect`.

Closes altdesktop#137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants