Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race with _disconnect_monitor event in BlueZ #999

Merged
merged 3 commits into from
Sep 12, 2022

Conversation

bdraco
Copy link
Contributor

@bdraco bdraco commented Sep 12, 2022

If the device disconnects right away for any reason, the on_connected_changed callback fires and clears the disconnect_monitor_event which results in the following exception:

  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 182, in connect
    asyncio.ensure_future(self._disconnect_monitor())
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 615, in ensure_future
    return _ensure_future(coro_or_future, loop=loop)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 636, in _ensure_future
    return loop.create_task(coro_or_future)
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 240, in _disconnect_monitor
    await self._disconnect_monitor_event.wait()
AttributeError: NoneType object has no attribute wait

If the device disconnects right away for any reason, the
on_connected_changed callback fires and clears the
disconnect_monitor_event which results in the following
exception:

```
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 182, in connect
    asyncio.ensure_future(self._disconnect_monitor())
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 615, in ensure_future
    return _ensure_future(coro_or_future, loop=loop)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 636, in _ensure_future
    return loop.create_task(coro_or_future)
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/client.py", line 240, in _disconnect_monitor
    await self._disconnect_monitor_event.wait()
AttributeError: NoneType object has no attribute wait
```
@bdraco bdraco marked this pull request as ready for review September 12, 2022 13:26
@dlech dlech merged commit df6985c into hbldh:develop Sep 12, 2022
@dlech
Copy link
Collaborator

dlech commented Sep 12, 2022

merged, thanks!

@dlech dlech mentioned this pull request Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants