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: ensure timeout does not raise cancellation #46

Merged
merged 3 commits into from
Apr 25, 2024
Merged

fix: ensure timeout does not raise cancellation #46

merged 3 commits into from
Apr 25, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Apr 25, 2024

fixes

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 319, in async_setup_entry
    adapter = await manager.async_get_adapter_from_address_or_recover(address)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/habluetooth/manager.py", line 240, in async_get_adapter_from_address_or_recover
  File "src/habluetooth/manager.py", line 249, in _async_recover_failed_adapters
  File "src/habluetooth/manager.py", line 256, in habluetooth.manager.BluetoothManager._async_recover_failed_adapters
  File "/usr/local/lib/python3.12/site-packages/habluetooth/util.py", line 13, in async_reset_adapter
    return await recover_adapter(adapter_id, mac_address)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/__init__.py", line 31, in recover_adapter
    return await recover_module.recover_adapter(hci, mac)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 407, in recover_adapter
    if adapter and await _power_cycle_adapter(adapter):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 482, in _power_cycle_adapter
    return await _execute_reset(adapter)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 593, in _execute_reset
    await _execute_power_off(adapter, name, power_state_before_reset)
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 672, in _execute_power_off
    await adapter.set_powered(False)
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 288, in set_powered
    response = await self.protocol.send(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 166, in send
    return await self.future
           ^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError

fixes
```
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 319, in async_setup_entry
    adapter = await manager.async_get_adapter_from_address_or_recover(address)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/habluetooth/manager.py", line 240, in async_get_adapter_from_address_or_recover
  File "src/habluetooth/manager.py", line 249, in _async_recover_failed_adapters
  File "src/habluetooth/manager.py", line 256, in habluetooth.manager.BluetoothManager._async_recover_failed_adapters
  File "/usr/local/lib/python3.12/site-packages/habluetooth/util.py", line 13, in async_reset_adapter
    return await recover_adapter(adapter_id, mac_address)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/__init__.py", line 31, in recover_adapter
    return await recover_module.recover_adapter(hci, mac)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 407, in recover_adapter
    if adapter and await _power_cycle_adapter(adapter):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 482, in _power_cycle_adapter
    return await _execute_reset(adapter)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 593, in _execute_reset
    await _execute_power_off(adapter, name, power_state_before_reset)
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 672, in _execute_power_off
    await adapter.set_powered(False)
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 288, in set_powered
    response = await self.protocol.send(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 166, in send
    return await self.future
           ^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError
```
fixes
```
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 319, in async_setup_entry
    adapter = await manager.async_get_adapter_from_address_or_recover(address)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/habluetooth/manager.py", line 240, in async_get_adapter_from_address_or_recover
  File "src/habluetooth/manager.py", line 249, in _async_recover_failed_adapters
  File "src/habluetooth/manager.py", line 256, in habluetooth.manager.BluetoothManager._async_recover_failed_adapters
  File "/usr/local/lib/python3.12/site-packages/habluetooth/util.py", line 13, in async_reset_adapter
    return await recover_adapter(adapter_id, mac_address)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/__init__.py", line 31, in recover_adapter
    return await recover_module.recover_adapter(hci, mac)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 407, in recover_adapter
    if adapter and await _power_cycle_adapter(adapter):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 482, in _power_cycle_adapter
    return await _execute_reset(adapter)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 593, in _execute_reset
    await _execute_power_off(adapter, name, power_state_before_reset)
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 672, in _execute_power_off
    await adapter.set_powered(False)
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 288, in set_powered
    response = await self.protocol.send(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 166, in send
    return await self.future
           ^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError
```
fixes
```
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 575, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/__init__.py", line 319, in async_setup_entry
    adapter = await manager.async_get_adapter_from_address_or_recover(address)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "src/habluetooth/manager.py", line 240, in async_get_adapter_from_address_or_recover
  File "src/habluetooth/manager.py", line 249, in _async_recover_failed_adapters
  File "src/habluetooth/manager.py", line 256, in habluetooth.manager.BluetoothManager._async_recover_failed_adapters
  File "/usr/local/lib/python3.12/site-packages/habluetooth/util.py", line 13, in async_reset_adapter
    return await recover_adapter(adapter_id, mac_address)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/__init__.py", line 31, in recover_adapter
    return await recover_module.recover_adapter(hci, mac)  # type: ignore
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 407, in recover_adapter
    if adapter and await _power_cycle_adapter(adapter):
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 482, in _power_cycle_adapter
    return await _execute_reset(adapter)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 593, in _execute_reset
    await _execute_power_off(adapter, name, power_state_before_reset)
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 672, in _execute_power_off
    await adapter.set_powered(False)
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 288, in set_powered
    response = await self.protocol.send(
               ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/bluetooth_auto_recovery/recover.py", line 166, in send
    return await self.future
           ^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError
```
@bdraco bdraco merged commit 4575fdd into main Apr 25, 2024
9 checks passed
@bdraco bdraco deleted the cancel_fix branch April 25, 2024 20:02
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.

1 participant