core: Several RuntimeError in different integrations (mostly aioesphomeapi)

The problem

Similar to #102495, maybe even duplicate, but still present.

What version of Home Assistant Core has the issue?

2023.10.5

What was the last working version of Home Assistant Core?

2023.10.3

What type of installation are you running?

Home Assistant Container

Integration causing the issue

esphome, wled, sabnzbd, webostv, hue, overkiz

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-10-23 15:54:16.960 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration webrtc which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.961 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration alarmo which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.961 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration watchman which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.961 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration xiaomi_miio_fan which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.962 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration blitzortung which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.962 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration multiscrape which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.962 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration eufy_security which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.963 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration lghorizon which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.963 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration media_player_template which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.964 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration afvalbeheer which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.964 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration car_wash which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.964 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration p2000 which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.964 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration kamstrup_403 which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.965 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration ical which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.965 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration xiaomi_miio which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:54:16.965 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration knmi which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-10-23 15:55:00.429 WARNING (MainThread) [homeassistant.setup] Setup of scrape is taking over 10 seconds.
2023-10-23 15:55:00.499 WARNING (MainThread) [homeassistant.setup] Setup of multiscrape is taking over 10 seconds.
2023-10-23 15:55:06.589 WARNING (MainThread) [homeassistant.helpers.entity] Entity None (<class 'custom_components.xiaomi_miio.fan.XiaomiAirPurifierMiot'>) is implicitly using device name by not setting its name. Instead, the name should be set to None, please report it to the custom integration author
2023-10-23 15:55:11.593 WARNING (MainThread) [homeassistant.components.fan] Platform xiaomi_miio_fan not ready yet: Unable to discover the device 192.168.68.137; Retrying in background in 30 seconds
2023-10-23 15:55:17.053 WARNING (MainThread) [homeassistant.config_entries] Config entry 'Achtertuin' for wled integration not ready yet: Invalid response from API: Error occurred while communicating with WLED device at 192.168.68.121; Retrying in background
2023-10-23 15:59:52.580 WARNING (MainThread) [aioesphomeapi.connection] watermeter @ 192.168.68.128: Connection error occurred: Ping response not received after 90.0 seconds
2023-10-23 16:00:00.141 WARNING (MainThread) [homeassistant.helpers.script.trigger_update_coordinator] Trigger Update Coordinator: Running script requires passing in a context
2023-10-23 16:10:00.161 WARNING (MainThread) [homeassistant.helpers.script.trigger_update_coordinator] Trigger Update Coordinator: Running script requires passing in a context
2023-10-23 16:10:38.140 ERROR (MainThread) [custom_components.xiaomi_miio] Error fetching Mi Air Purifier 3/3H data: Unable to discover the device 192.168.68.104
2023-10-23 16:20:00.141 WARNING (MainThread) [homeassistant.helpers.script.trigger_update_coordinator] Trigger Update Coordinator: Running script requires passing in a context
2023-10-23 16:20:54.140 ERROR (MainThread) [custom_components.xiaomi_miio] Error fetching Mi Air Purifier 3/3H data: Unable to discover the device 192.168.68.104
2023-10-23 16:25:21.249 ERROR (MainThread) [custom_components.xiaomi_miio] Error fetching Mi Air Purifier 3/3H data: Unable to discover the device 192.168.68.104
2023-10-23 16:27:26.138 ERROR (MainThread) [custom_components.xiaomi_miio] Error fetching Mi Air Purifier 3/3H data: Unable to discover the device 192.168.68.104
2023-10-23 16:27:31.241 WARNING (MainThread) [aioesphomeapi.connection] particulate_matter @ 192.168.68.134: Connection error occurred: Ping response not received after 90.0 seconds
2023-10-23 16:28:02.356 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback APIFrameHelper._set_ready_future_exception(<class 'TimeoutError'>)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
TypeError: Argument 'exc' has incorrect type (expected Exception, got type)
2023-10-23 16:28:03.454 ERROR (MainThread) [custom_components.xiaomi_miio] Error fetching Mi Air Purifier 3/3H data: Unable to discover the device 192.168.68.104
2023-10-23 16:29:16.648 WARNING (MainThread) [homeassistant.components.esphome.manager] Error getting initial data for 192.168.68.134: Timeout waiting for response for <class 'api_pb2.ListEntitiesRequest'> after 60.0s
2023-10-23 16:29:26.651 ERROR (MainThread) [aioesphomeapi.connection] particulate_matter @ 192.168.68.134: Failed to send disconnect request: Timeout waiting for response for <class 'api_pb2.DisconnectRequest'> after 10.0s
2023-10-23 16:30:00.143 WARNING (MainThread) [homeassistant.helpers.script.trigger_update_coordinator] Trigger Update Coordinator: Running script requires passing in a context
2023-10-23 16:30:04.529 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback APIFrameHelper._set_ready_future_exception(<class 'TimeoutError'>)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
TypeError: Argument 'exc' has incorrect type (expected Exception, got type)
2023-10-23 16:31:34.528 ERROR (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for particulate_matter @ 192.168.68.134: Unexpected error while connecting to particulate_matter @ 192.168.68.134:  (UnhandledAPIConnectionError)
Traceback (most recent call last):
  File "aioesphomeapi/connection.py", line 552, in aioesphomeapi.connection.APIConnection.finish_connection
  File "aioesphomeapi/connection.py", line 526, in _do_finish_connect
  File "aioesphomeapi/connection.py", line 366, in _connect_init_frame_helper
  File "aioesphomeapi/_frame_helper/noise.py", line 139, in perform_handshake
  File "aioesphomeapi/_frame_helper/base.py", line 121, in perform_handshake
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 374, in finish_connection
    await self._connection.finish_connection(login=login)
  File "aioesphomeapi/connection.py", line 565, in finish_connection
  File "aioesphomeapi/connection.py", line 551, in aioesphomeapi.connection.APIConnection.finish_connection
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/reconnect_logic.py", line 173, in _try_connect
    await self._cli.finish_connection(login=True)
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 380, in finish_connection
    raise UnhandledAPIConnectionError(
aioesphomeapi.core.UnhandledAPIConnectionError: Unexpected error while connecting to particulate_matter @ 192.168.68.134: 
2023-10-23 16:31:36.578 ERROR (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for particulate_matter @ 192.168.68.134: Unexpected error while connecting to particulate_matter @ 192.168.68.134: File descriptor 33 is used by transport <_SelectorSocketTransport fd=33 read=polling write=<idle, bufsize=0>> (UnhandledAPIConnectionError)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 636, in _sock_connect
    sock.connect(address)
BlockingIOError: [Errno 115] Operation in progress

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 357, in start_connection
    await self._connection.start_connection()
  File "aioesphomeapi/connection.py", line 517, in start_connection
  File "aioesphomeapi/connection.py", line 504, in aioesphomeapi.connection.APIConnection.start_connection
  File "aioesphomeapi/connection.py", line 505, in aioesphomeapi.connection.APIConnection.start_connection
  File "aioesphomeapi/connection.py", line 483, in _do_connect
  File "aioesphomeapi/connection.py", line 318, in _connect_socket_connect
  File "aioesphomeapi/connection.py", line 319, in aioesphomeapi.connection.APIConnection._connect_socket_connect
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 626, in sock_connect
    self._sock_connect(fut, sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
    self._ensure_fd_no_transport(fd)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 257, in _ensure_fd_no_transport
    raise RuntimeError(
RuntimeError: File descriptor 33 is used by transport <_SelectorSocketTransport fd=33 read=polling write=<idle, bufsize=0>>

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/reconnect_logic.py", line 161, in _try_connect
    await self._cli.start_connection(on_stop=self._on_disconnect)
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 363, in start_connection
    raise UnhandledAPIConnectionError(
aioesphomeapi.core.UnhandledAPIConnectionError: Unexpected error while connecting to particulate_matter @ 192.168.68.134: File descriptor 33 is used by transport <_SelectorSocketTransport fd=33 read=polling write=<idle, bufsize=0>>
2023-10-23 16:32:16.108 WARNING (MainThread) [aioesphomeapi.connection] particulate_matter @ 192.168.68.134: Connection error occurred: particulate_matter @ 192.168.68.134: Connection lost
2023-10-23 16:32:38.723 WARNING (MainThread) [aioesphomeapi.connection] particulate_matter @ 192.168.68.134: Connection error occurred: particulate_matter @ 192.168.68.134: Connection lost
2023-10-23 16:33:19.742 WARNING (MainThread) [aioesphomeapi.connection] particulate_matter @ 192.168.68.134: Connection error occurred: Timeout waiting for response for <class 'api_pb2.ConnectRequest'> after 30.0s
2023-10-23 16:33:40.677 WARNING (MainThread) [aioesphomeapi.connection] particulate_matter @ 192.168.68.134: Connection error occurred: particulate_matter @ 192.168.68.134: Connection lost
2023-10-23 16:34:25.951 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback APIFrameHelper._set_ready_future_exception(<class 'TimeoutError'>)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
TypeError: Argument 'exc' has incorrect type (expected Exception, got type)
2023-10-23 16:35:55.947 ERROR (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for particulate_matter @ 192.168.68.134: Unexpected error while connecting to particulate_matter @ 192.168.68.134:  (UnhandledAPIConnectionError)
Traceback (most recent call last):
  File "aioesphomeapi/connection.py", line 552, in aioesphomeapi.connection.APIConnection.finish_connection
  File "aioesphomeapi/connection.py", line 526, in _do_finish_connect
  File "aioesphomeapi/connection.py", line 366, in _connect_init_frame_helper
  File "aioesphomeapi/_frame_helper/noise.py", line 139, in perform_handshake
  File "aioesphomeapi/_frame_helper/base.py", line 121, in perform_handshake
asyncio.exceptions.CancelledError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 374, in finish_connection
    await self._connection.finish_connection(login=login)
  File "aioesphomeapi/connection.py", line 565, in finish_connection
  File "aioesphomeapi/connection.py", line 551, in aioesphomeapi.connection.APIConnection.finish_connection
  File "/usr/local/lib/python3.11/asyncio/timeouts.py", line 111, in __aexit__
    raise TimeoutError from exc_val
TimeoutError

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/reconnect_logic.py", line 173, in _try_connect
    await self._cli.finish_connection(login=True)
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 380, in finish_connection
    raise UnhandledAPIConnectionError(
aioesphomeapi.core.UnhandledAPIConnectionError: Unexpected error while connecting to particulate_matter @ 192.168.68.134: 
2023-10-23 16:36:01.142 ERROR (MainThread) [homeassistant.components.wled] Unexpected error fetching wled data: File descriptor 36 is used by transport <_SelectorSocketTransport fd=36 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 636, in _sock_connect
    sock.connect(address)
BlockingIOError: [Errno 115] Operation in progress

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/wled/coordinator.py", line 103, in _async_update_data
    device = await self.wled.update(full_update=not self.last_update_success)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wled/wled.py", line 294, in update
    if not (presets := await self.request("/presets.json")):
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wled/wled.py", line 188, in request
    response = await self.session.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 626, in sock_connect
    self._sock_connect(fut, sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
    self._ensure_fd_no_transport(fd)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 257, in _ensure_fd_no_transport
    raise RuntimeError(
RuntimeError: File descriptor 36 is used by transport <_SelectorSocketTransport fd=36 read=polling write=<idle, bufsize=0>>
2023-10-23 16:36:21.143 ERROR (MainThread) [homeassistant.components.wled] Unexpected error fetching wled data: File descriptor 36 is used by transport <_SelectorSocketTransport fd=36 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 636, in _sock_connect
    sock.connect(address)
BlockingIOError: [Errno 115] Operation in progress

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/wled/coordinator.py", line 103, in _async_update_data
    device = await self.wled.update(full_update=not self.last_update_success)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wled/wled.py", line 294, in update
    if not (presets := await self.request("/presets.json")):
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wled/wled.py", line 188, in request
    response = await self.session.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 626, in sock_connect
    self._sock_connect(fut, sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
    self._ensure_fd_no_transport(fd)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 257, in _ensure_fd_no_transport
    raise RuntimeError(
RuntimeError: File descriptor 36 is used by transport <_SelectorSocketTransport fd=36 read=polling write=<idle, bufsize=0>>
2023-10-23 16:36:22.165 ERROR (MainThread) [homeassistant.components.overkiz] Unexpected error fetching device events data: File descriptor 36 is used by transport <_SelectorSocketTransport fd=36 read=polling write=<idle, bufsize=0>>
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 636, in _sock_connect
    sock.connect(address)
BlockingIOError: [Errno 115] Operation in progress

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/overkiz/coordinator.py", line 71, in _async_update_data
    events = await self.client.fetch_events()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 563, in fetch_events
    response = await self.__post(f"events/{self.event_listener_id}/fetch")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyoverkiz/client.py", line 786, in __post
    async with self.session.post(
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in __aenter__
    self._resp = await self._coro
                 ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 626, in sock_connect
    self._sock_connect(fut, sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
    self._ensure_fd_no_transport(fd)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 257, in _ensure_fd_no_transport
    raise RuntimeError(
RuntimeError: File descriptor 36 is used by transport <_SelectorSocketTransport fd=36 read=polling write=<idle, bufsize=0>>
2023-10-23 16:36:36.308 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 636, in _sock_connect
    sock.connect(address)
BlockingIOError: [Errno 115] Operation in progress

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/sabnzbd/__init__.py", line 235, in async_update_sabnzbd
    await sab_api.refresh_data()
  File "/usr/local/lib/python3.11/site-packages/pysabnzbd/__init__.py", line 55, in refresh_data
    queue = await self.get_queue()
            ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysabnzbd/__init__.py", line 72, in get_queue
    queue = await self._call(params)
            ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysabnzbd/__init__.py", line 38, in _call
    resp = await self._session.get(
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request
    conn = await self._connector.connect(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect
    proto = await self._create_connection(req, traces, timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 626, in sock_connect
    self._sock_connect(fut, sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
    self._ensure_fd_no_transport(fd)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 257, in _ensure_fd_no_transport
    raise RuntimeError(
RuntimeError: File descriptor 36 is used by transport <_SelectorSocketTransport fd=36 read=polling write=<idle, bufsize=0>>
2023-10-23 16:36:55.983 ERROR (MainThread) [aioesphomeapi.reconnect_logic] Can't connect to ESPHome API for particulate_matter @ 192.168.68.134: Unexpected error while connecting to particulate_matter @ 192.168.68.134: File descriptor 36 is used by transport <_SelectorSocketTransport fd=36 read=polling write=<idle, bufsize=0>> (UnhandledAPIConnectionError)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 636, in _sock_connect
    sock.connect(address)
BlockingIOError: [Errno 115] Operation in progress

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 357, in start_connection
    await self._connection.start_connection()
  File "aioesphomeapi/connection.py", line 517, in start_connection
  File "aioesphomeapi/connection.py", line 504, in aioesphomeapi.connection.APIConnection.start_connection
  File "aioesphomeapi/connection.py", line 505, in aioesphomeapi.connection.APIConnection.start_connection
  File "aioesphomeapi/connection.py", line 483, in _do_connect
  File "aioesphomeapi/connection.py", line 318, in _connect_socket_connect
  File "aioesphomeapi/connection.py", line 319, in aioesphomeapi.connection.APIConnection._connect_socket_connect
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 626, in sock_connect
    self._sock_connect(fut, sock, address)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 642, in _sock_connect
    self._ensure_fd_no_transport(fd)
  File "/usr/local/lib/python3.11/asyncio/selector_events.py", line 257, in _ensure_fd_no_transport
    raise RuntimeError(
RuntimeError: File descriptor 36 is used by transport <_SelectorSocketTransport fd=36 read=polling write=<idle, bufsize=0>>

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

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/reconnect_logic.py", line 161, in _try_connect
    await self._cli.start_connection(on_stop=self._on_disconnect)
  File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 363, in start_connection
    raise UnhandledAPIConnectionError(
aioesphomeapi.core.UnhandledAPIConnectionError: Unexpected error while connecting to particulate_matter @ 192.168.68.134: File descriptor 36 is used by transport <_SelectorSocketTransport fd=36 read=polling write=<idle, bufsize=0>>
2023-10-23 16:38:29.866 WARNING (MainThread) [aioesphomeapi.connection] particulate_matter @ 192.168.68.134: Connection error occurred: particulate_matter @ 192.168.68.134: Connection lost
2023-10-23 16:38:33.578 ERROR (MainThread) [custom_components.xiaomi_miio] Error fetching Mi Air Purifier 3/3H data: Unable to discover the device 192.168.68.104
2023-10-23 16:38:59.898 ERROR (MainThread) [homeassistant] Error doing job: Exception in callback APIFrameHelper._set_ready_future_exception(<class 'TimeoutError'>)
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
TypeError: Argument 'exc' has incorrect type (expected Exception, got type)
2023-10-23 16:40:00.142 WARNING (MainThread) [homeassistant.helpers.script.trigger_update_coordinator] Trigger Update Coordinator: Running script requires passing in a context
2023-10-23 16:45:03.133 ERROR (MainThread) [custom_components.xiaomi_miio] Timeout fetching Mi Air Purifier 3/3H data

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 19 (18 by maintainers)

Commits related to this issue

Most upvoted comments

All the linked PRs are merged and will be in 2023.11.0 on Wednesday

Got it running for 90 minutes, no issues so far. Will keep you posted.

With what you said I think I understand the problem on my side, I have an ESPHome device outside (particulate_matter) and when it rains, the Wi-Fi connection is becoming very unstable.

Leaving this open until confirmation that all is good tomorrow

Everything looks good so far, no errors, and all light automations are still working.

Shall I give another update tomorrow?

Yes please. I’ll get the linked PR merged and reopen this when it merges.

Is there anything specific you want me to verify?

Whatever you were doing before that caused it to happen (if thats nothing than do nothing)