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

Avoid reusing the MessageBus in the manager #920

Merged
merged 2 commits into from
Aug 3, 2022

Conversation

bdraco
Copy link
Contributor

@bdraco bdraco commented Aug 2, 2022

When the dbus socket gets disconnected from dbus, we cannot
reuse the connection because dbus-next finalize will remove
the underlying fds

Fixes

2022-08-02 09:29:00.722 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Bluetooth for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 253, in async_setup_entry
    await manager.async_start(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 343, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 808, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 290, in async_init
    await self._bus.connect()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 149, in connect
    await self._authenticate()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 380, in _authenticate
    await self._loop.sock_sendall(self._sock, b0)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 441, in sock_sendall
    n = sock.send(data)
BrokenPipeError: [Errno 32] Broken pipe

When the dbus socket gets disconnected from dbus, we cannot
reuse the connection because dbus-next finalize will remove
the underlying fds

Fixes
```
2022-08-02 09:29:00.722 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry Bluetooth for bluetooth
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 357, in async_setup
    result = await component.async_setup_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 253, in async_setup_entry
    await manager.async_start(
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 343, in async_start
    await self.scanner.start()  # type: ignore[no-untyped-call]
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 128, in start
    manager = await get_global_bluez_manager()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 808, in get_global_bluez_manager
    await instance.async_init()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/manager.py", line 290, in async_init
    await self._bus.connect()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 149, in connect
    await self._authenticate()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 380, in _authenticate
    await self._loop.sock_sendall(self._sock, b0)
  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 441, in sock_sendall
    n = sock.send(data)
BrokenPipeError: [Errno 32] Broken pipe
```
@bdraco bdraco force-pushed the no_reuse_dbus_socket_manager branch from f0293fd to c581d5e Compare August 2, 2022 20:57
@dlech dlech changed the base branch from develop to release/v0.15.1 August 3, 2022 14:37
@dlech dlech changed the base branch from release/v0.15.1 to develop August 3, 2022 14:38
@dlech dlech changed the base branch from develop to release/v0.15.1 August 3, 2022 14:38
@dlech dlech changed the base branch from release/v0.15.1 to develop August 3, 2022 14:40
@dlech dlech merged commit 90ead61 into hbldh:develop Aug 3, 2022
@dlech dlech mentioned this pull request Aug 3, 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.

None yet

2 participants