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

Closing things down cleanly #191

Open
pcollinson opened this issue May 30, 2024 · 0 comments
Open

Closing things down cleanly #191

pcollinson opened this issue May 30, 2024 · 0 comments

Comments

@pcollinson
Copy link

pcollinson commented May 30, 2024

If I run your second example on the README page, to connect with an IP address, the output ends with:

Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f254e230390>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f254e248910>, 1996610.550300446)]']
connector: <aiohttp.connector.TCPConnector object at 0x7f254f0e2710>

I've got a daemon running that talks to several plugs and I want to cleanly close things down when I am done with one plug.

I'm unsure to how to do this. Ideally I'd just like to call close() on the class that initialises things, and have this call close() on the object returned by the connect() calls - and for that to get rid of the running aiohttp session.

Well, after some confusion, I've found a reference to close the session.

If self._client is the object returned by connect(), then

await self._client.client.protocol.close()

finds the lurking aiohttp() session. This seems to be some way down the tree of code, can we have a more transparent way?

_client is a TapoPlug
_client.client is a TapoClient

If TapoClient had a close() function then it would be transparent. Is this a possibility?

ano0002 added a commit to ano0002/plugp100 that referenced this issue Jul 23, 2024
Fixed client not being properly closed when guessing the protocol
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

No branches or pull requests

1 participant