petretiandrea / plugp100

Work in progress implementation of tapo protocol in python.
GNU General Public License v3.0
71 stars 27 forks source link

Unclosed client session #144

Open R4ykoo opened 1 year ago

R4ykoo commented 1 year ago

Hey, thank you for your work.

I'm working on making an API that waits for requests to turn on bulbs (L530E) with certain colors. The server receives a request with the color which the bulb must turn into, then the server connects to the TapoClient and LightDevice to make it happen.

This works flawlessly but after every request is done I get the following warning:

Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x00000219B00A2050>

I've tried closing the connection on the tapoClient after setting the color: await light.set_hue_saturation(data['color'], saturation=100) await light.set_brightness(data['brightness']) await client.close() return Response(status=200, mimetype='application/json')

But doesn't work.

I've tried putting the whole server inside a context manager to close the aiohttp session, just as your code example, but I'm unable to make it right apparently.

Is there any kind of workaround?

Thank you for your time.

Kiwiwatcher commented 9 months ago

Good morning, I wondering if there is an update on this issue, and if it is really just a "cosmetic issue", or does it causes impacts such as memory leaks through reallocation to memory resources at each call that are not freed up until the main function exits?

Thank you