You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run the device discovery code from the bleak Bluetooth library
import asyncio
from bleak import BleakScanner
async def main():
devices = await BleakScanner.discover()
for d in devices:
print(d)
asyncio.run(main())
but keep getting the following error,
asyncio.run() cannot be called from a running event loop
Full traceback,
Traceback (most recent call last):
File ~\.conda\envs\BLE\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File c:\users\sengnr3\.spyder-py3\temp.py:18
asyncio.run(main())
File ~\.conda\envs\BLE\Lib\asyncio\runners.py:190 in run
raise RuntimeError(
RuntimeError: asyncio.run() cannot be called from a running event loop
The code runs as expected when called from the command line.
The text was updated successfully, but these errors were encountered:
Hi @Nic-Roberts-Hud thank you for the report! I think if you are running IPython >=7 you should be able to run your code changing it to be something like:
Win 11 x64, Python 3.12, Spyder 5.5.1
I'm trying to run the device discovery code from the
bleak
Bluetooth librarybut keep getting the following error,
asyncio.run() cannot be called from a running event loop
Full traceback,
The code runs as expected when called from the command line.
The text was updated successfully, but these errors were encountered: