0

I'm trying to use Bleak , a Python library for Bluetooth devices management. Starting from an example of use to find active Bluetooth devices

import asyncio
from bleak import BleakScanner

async def main():
    devices = await BleakScanner.discover()
    for d in devices:
        print(d)

asyncio.run(main())

I get a

File "C:\Users\ \Desktop\Python_BLE.py", line 25, in <module>
    asyncio.run(main())

File "C:\Users\ \Miniconda3\lib\asyncio\runners.py", line 34, in run
    "asyncio.run() cannot be called from a running event loop")

RuntimeError: asyncio.run() cannot be called from a running event loop

I'm running it on Spyder 5.2.2 with Python 3.7.10.

eljamba
  • 171
  • 1
  • 2
  • 11
  • Show the full traceback of the error as properly formatted text (formatted as code) in the question. – Michael Butscher Mar 09 '23 at 11:24
  • `File "C:\Users\...\Desktop\Python_BLE.py", line 25, in ` Unless I'm sorely mistaken, there aren't 25 lines of code in your example. – AKX Mar 09 '23 at 11:39
  • Line 25 corresponds to _asyncio.run(main())_ as stated in the code. Missing lines are comments auto-generated by the editor. – eljamba Mar 09 '23 at 12:00

0 Answers0