blinkpy icon indicating copy to clipboard operation
blinkpy copied to clipboard

Warning: Unclosed client session / Unclosed connector

Open MarkusKress opened this issue 2 years ago • 5 comments

Got these warnings. Should I close the session and how can I do it?

MarkusKress avatar Jan 10 '24 14:01 MarkusKress

Also receiving these warnings. To reproduce:

import asyncio from aiohttp import ClientSession from blinkpy.blinkpy import Blink from blinkpy.auth import Auth

async def start(): ....blink = Blink(session=ClientSession()) ....# In the following XXX are replaced with my username and my password ....auth = Auth({"username": XXX, "password": XXX}, no_prompt=True) ....blink.auth = auth ....await blink.start() ....return blink

blink = asyncio.run(start())

annealer avatar Jan 11 '24 20:01 annealer

Follow something like this example. https://github.com/fronzbot/blinkpy/blob/7d0e1f6cbb4b571c556e1e7c8ee1d87d1f0257d3/blinksync/blinksync.py#L102-L103

mkmer avatar Jan 11 '24 20:01 mkmer

Follow something like this example.

https://github.com/fronzbot/blinkpy/blob/7d0e1f6cbb4b571c556e1e7c8ee1d87d1f0257d3/blinksync/blinksync.py#L102-L103

Understood, but what to do after aborting (^C) a run while a seesion is open? How to check for and close a zombie session?

annealer avatar Jan 11 '24 21:01 annealer

It doesn't really matter, when you ^C it kills python - it's just a warning informing you that things were not closed as they should be programmatically.
You may be able to put a try: test around the whole code and catch except KeyboardInterrupt: then close the session if you really need it.

mkmer avatar Jan 12 '24 12:01 mkmer

There hasn't been any activity on this issue recently. Please make sure to update to the latest blinkpy version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Mar 12 '24 13:03 github-actions[bot]