Bleak error
Hello, i'm having trouble when scanning, got this error :
libpng warning: iCCP: known incorrect sRGB profile
Traceback (most recent call last):
File "C:\Users\Tatane\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\qasync\__init__.py", line 780, in _error_handler
task.result()
File "C:\Users\Tatane\Downloads\HappyLighting-py-master\LEDStripController\pyhl.py", line 284, in handle_scan
devices = await BLEClass.BleakScanner.discover(timeout=8.0)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Tatane\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\bleak\__init__.py", line 320, in discover
async with cls(**kwargs) as scanner:
File "C:\Users\Tatane\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\bleak\__init__.py", line 158, in __aenter__
await self._backend.start()
File "C:\Users\Tatane\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\bleak\backends\winrt\scanner.py", line 222, in start
assert_mta()
File "C:\Users\Tatane\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\bleak\backends\winrt\util.py", line 78, in assert_mta
raise BleakError(
bleak.exc.BleakError: The current thread apartment type is not MTA: STA. Beware of packages like pywin32 that may change the apartment type implicitly.
have you installed requirements via requirements.txt?
have you installed requirements via requirements.txt?
Yeah I did
Tried to replicate it and it happens to me only if I try to press search multiple time. I think that this is not your case right?
Hello, sorry for the long responce, No I don't press the search button multiple times, maybe I don't understand how to use it. I link a gif of the error.
This issue usually happens because Bleak needs to run in a Multi Threaded Apartment (MTA); hence, the reason you get the BleakError.
Try adding sys.coinit_flags = 0 after importing sys at the top of the file:
import sys
sys.coinit_flags = 0 # 0 means MTA
# Other packages below
More information on these errors here.
you can make a pull request about it if you want