chiefwigms / picobrew_pico

MIT License
149 stars 63 forks source link

move infinite loop within the spawned async thread vs outside #275

Closed tmack8001 closed 3 years ago

tmack8001 commented 3 years ago

Moving the while True loop within the async function method for scanning for tilt devices prevents an onslaught of run away threads all fighting over system resources and ultimately the bluetooth device (only one thread can scan anyways).

cc/ @cgalpin and @Intecpsp who have also been helping identify that this was related to the Tilt polling. Though my raspberrypi never fell over or become unresponsive others have reported this in https://github.com/chiefwigms/picobrew_pico/issues/274 and in PMs.

tmack8001 commented 3 years ago

Having something similar to this running on my Pi (not the exact same as I cleaned a few debug stuff up) I was able to get a consistent 10-16 over 30 minutes whereas before there would be 100+ open file descriptors mostly being pipe descriptors pointing to python3 processes.

pi@picobrew-logger:~ $ sudo ls -l /proc/879/fd | wc -l
16
pi@picobrew-logger:~ $ sudo ls -l /proc/879/fd | wc -l
16
pi@picobrew-logger:~ $ sudo ls -l /proc/879/fd | wc -l
13