bleak: Windows 10 TimeOut Error

  • bleak version: 22.2.2
  • Python version: 3.11
  • Operating System: Windows 10
  • BlueZ version (bluetoothctl -v) in case of Linux:

Description

I’m trying to run a custom script to connect to a peripheral. This script works perfectly on my Mac and on my other Windows 10, and everything works, but when trying to set it up on a new Windows 10 laptop, I keep getting this TimeOut error.

What I Did

This is the error that I get:

Traceback (most recent call last):
  File "C:\Users\Celia\Scripts\Python\csblesimp.py", line 103, in <module>
    loop.run_until_complete(main())
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Users\Celia\Scripts\Python\csblesimp.py", line 85, in main
    await data_client(device)
  File "C:\Users\Celia\Scripts\Python\csblesimp.py", line 31, in data_client
    async with BleakClient(device) as client:
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\__init__.py", line 433, in __aenter__
    await self.connect()
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\__init__.py", line 471, in connect
    return await self._backend.connect(**kwargs)
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\backends\winrt\client.py", line 380, in connect
    await asyncio.gather(wait_connect_task, wait_get_services_task)
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\backends\winrt\client.py", line 612, in get_services
    get_services_task.result(),
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\backends\winrt\client.py", line 933, in result
    return self._async_result.get_results()
OSError: [WinError -2147483629] The object has been closed

= RESTART: C:\Users\Celia\Scripts\Python\csblesimp.py

Warning (from warnings module):
  File "C:\Users\Celia\Scripts\Python\csblesimp.py", line 101
    loop = asyncio.get_event_loop()
DeprecationWarning: There is no current event loop
Device: DE:D3:4D:CA:60:FD
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\backends\winrt\client.py", line 380, in connect
    await asyncio.gather(wait_connect_task, wait_get_services_task)
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Celia\Scripts\Python\csblesimp.py", line 103, in <module>
    loop.run_until_complete(main())
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
    return future.result()
  File "C:\Users\Celia\Scripts\Python\csblesimp.py", line 85, in main
    await data_client(device)
  File "C:\Users\Celia\Scripts\Python\csblesimp.py", line 31, in data_client
    async with BleakClient(device) as client:
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\__init__.py", line 433, in __aenter__
    await self.connect()
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\__init__.py", line 471, in connect
    return await self._backend.connect(**kwargs)
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\bleak\backends\winrt\client.py", line 379, in connect
    async with async_timeout.timeout(timeout):
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\async_timeout\__init__.py", line 129, in __aexit__
    self._do_exit(exc_type)
  File "C:\Users\Celia\AppData\Local\Programs\Python\Python310\lib\site-packages\async_timeout\__init__.py", line 212, in _do_exit
    raise asyncio.TimeoutError

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 46

Most upvoted comments

OK, making progress now. I had a mistake in my latest change that caused the new exception. I just pushed the fix, so try uninstalling and installing the package again.