basnijholt / miflora

☘️🌑🌼πŸ₯€πŸ‘ Mi Flora Plant sensor Python package
MIT License
362 stars 99 forks source link

Potential threading lock issue, leading to threads summing up when MifloraPoller is constantly used #140

Closed psilo909 closed 4 years ago

psilo909 commented 4 years ago

Hi,

I am using MifloraPoller in a custom plugin for our software SmartHomeNG (https://github.com/smarthomeNG/plugins/tree/develop/miflora).

I think there is a potential bug concerning the thread lock release in case of exceptions.

Threads are summing up in my application every time the device is not reachable:

current thread sum for my 4 plugin instances, which are constantly reading data: plugins.miflora_xiaomi_2.plugins.miflora: 10, plugins.miflora_xiaomi_4.plugins.miflora: 9, plugins.miflora_xiaomi_3.plugins.miflora: 9, plugins.miflora_xiaomi_1.plugins.miflora: 9

I will investigate on your source code mid of next week when i have holidays. hopefully i find out. i suppose the threads in your code stay in locked state in case of exceptions, so that new threads are spawned. Perhaps you also have an idea. I am pretty sure that it is no bug in my plugin's code.

psilo909 commented 4 years ago

i close, i think with code from recent master branch problem does not occur anymore (btlewrap 0.0.9)