I have a python script that runs happily on its own. It is part of a much larger project and when trying to integrate into the main project, currently throws an error.
The log for a successful execution includes the following:
INFO:in scanner
INFO:Reading data for ['c4:56:58:0d:16:a9']
INFO:Received data from c4:56:58:0d:16:a9
INFO:file written
The log from with the main script includes:
DEBUG:in scanner
INFO:Reading data for ['c4:56:58:0d:16:a9']
ERROR:Task exception was never retrieved future: <Task finished name='Task-2' coro=<my_scan.<locals>.scan() done, defined at /home/pi/Device_scanner.py:181> exception=BleakDBusError('org.bluez.Error.InProgress', 'Operation already in progress')>
The offending error surfaced when the main project was expanded to include an additional function which used threading
and I worked on the suspicion that an active thread was blocking the scanner (which uses asyncio
)from completing.
I have since modified the additional coding that included the threading
and logged various points along the path up to the point where the scanner is called and with threading.enumerate()
now have a single thread active which is the main thread
.
The additonal threading
code and the scanner code have been successfully run in a scaled down script which crudely:
create thread
Run code
break from thread
sleep for 5 seconds
run scanner
Any suggestions of what may be causing the ERROR
and how to navigate?