Open brianreinhold opened 1 month ago
The concept turns out to work, I was just accessing the variable queue_scan as a global variable in the other module. The proper way to access it in the other module if I want to change it is to reference it as a module variable
import aioble_central
then where I want to reset it to True:
aioble_central.queue_scan = True,
This worked. On the MemoryError setting queue_scan to False blocked any further attempt to queue ScanResponses until the queue_scan is reset to True in the module handling the scan cycle (which in this case lasts for 10 seconds)
I am using the scanner as follows in my application code
However, every once and a while in the scan event handler a MemoryError is thrown while trying to load a result into the queue shown below:
I have added a handler for the exception and would like to be able to recover from the error but am not sure what else I need to do. With the code shown above, the scanner restarts after 10 seconds but ScanResult objects are no longer created. Not sure why. Do I need to set the event? Do I need to add a filter that blocks repeat advertisements in a given scan cycle? Maybe it is simply not possible to recover from such an error?
Any help is greatly appreciated, especially from the code author.