bleak icon indicating copy to clipboard operation
bleak copied to clipboard

examples/service_explorer.py Unhandled timeout error in service_explorer.py / CentralManagerDelegate.py on macOS

Open jsmif opened this issue 2 years ago • 1 comments

  • bleak version: bleak-0.21.0a
  • Python version: Python 3.11.3
  • Operating System: macOS 13.3.1 (a)

Description

Testing examples/service_explorer.py on macOS since it doesn't work for me on Linux (#1333 )

What I Did

python3 service_explorer.py --address F8607851-010B-B680-D5E6-55C07864A794
2023-06-14 09:06:40,788 __main__ INFO: starting scan...
2023-06-14 09:06:43,927 __main__ INFO: connecting to device...
Traceback (most recent call last):
  File "/Users/user/Desktop/tmp/bleak/bleak/backends/corebluetooth/CentralManagerDelegate.py", line 171, in connect
    await future
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/user/Desktop/tmp/bleak/examples/service_explorer.py", line 129, in <module>
    asyncio.run(main(args))
  File "/usr/local/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/user/Desktop/tmp/bleak/examples/service_explorer.py", line 41, in main
    async with BleakClient(
  File "/Users/user/Desktop/tmp/bleak/bleak/__init__.py", line 491, in __aenter__
    await self.connect()
  File "/Users/user/Desktop/tmp/bleak/bleak/__init__.py", line 531, in connect
    return await self._backend.connect(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/user/Desktop/tmp/bleak/bleak/backends/corebluetooth/client.py", line 125, in connect
    await manager.connect(self._peripheral, disconnect_callback, timeout=timeout)
  File "/Users/user/Desktop/tmp/bleak/bleak/backends/corebluetooth/CentralManagerDelegate.py", line 170, in connect
    async with async_timeout(timeout):
  File "/usr/local/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

This occurred when attempting to connect to an Apple AirTag that was listed by BleakScanner.discover(). Note, service_explorer.py has worked for me for at least one device though.

Logs

Unfortunately I cannot provide logs as that would provide my exact physical location (see: wigle.net)

jsmif avatar Jun 14 '23 13:06 jsmif

Did the OS prompt for any kind of authentication?

It is not possible to diagnose further without additional logs.

dlech avatar Jun 14 '23 14:06 dlech

This issue has been automatically closed because it has not had any activity for 100 days after being marked as stale.

github-actions[bot] avatar Oct 05 '25 02:10 github-actions[bot]