Home Assistant stops responding, with "'NoneType' object has no attribute 'sendto'" and "'NoneType' object has no attribute 'call_exception_handler'" in logs

Sometimes, Home Assistant will become unresponsive. Port 8123 immediately rejects the connection. If I check the logs, it seems like it gets stuck in a loop like this:

2022-05-02 21:48:33 WARNING (Thread-14) [pychromecast.socket_client] [Bedroom TV(192.168.0.23):8009] Error communicating with socket, resetting connection
2022-05-02 21:49:03 ERROR (Thread-14) [pychromecast.socket_client] [Bedroom TV(192.168.0.23):8009] Failed to connect to service ServiceInfo(type='host', data=('192.168.0.23', 8009)), retrying in 5.0s
2022-05-02 21:49:03 ERROR (Thread-14) [pychromecast.socket_client] [Bedroom TV(192.168.0.23):8009] Unhandled exception in worker thread, attempting reconnect
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1056, in sendto
    self._sock.sendto(data, addr)
AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pychromecast/socket_client.py", line 538, in run
    if self.run_once(timeout=POLL_TIME_BLOCKING) == 1:
  File "/usr/local/lib/python3.9/site-packages/pychromecast/socket_client.py", line 561, in run_once
    if not self._check_connection():
  File "/usr/local/lib/python3.9/site-packages/pychromecast/socket_client.py", line 690, in _check_connection
    self.initialize_connection()
  File "/usr/local/lib/python3.9/site-packages/pychromecast/socket_client.py", line 295, in initialize_connection
    host, port, service_info = get_host_from_service(
  File "/usr/local/lib/python3.9/site-packages/pychromecast/dial.py", line 38, in get_host_from_service
    service_info = zconf.get_service_info("_googlecast._tcp.local.", service.data)
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_core.py", line 533, in get_service_info
    if info.request(self, timeout, question_type):
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_services/info.py", line 462, in request
    return bool(run_coro_with_timeout(self.async_request(zc, timeout, question_type), zc.loop, timeout))
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_utils/asyncio.py", line 97, in run_coro_with_timeout
    return asyncio.run_coroutine_threadsafe(aw, loop).result(
  File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 445, in result
    return self.__get_result()
  File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_services/info.py", line 491, in async_request
    zc.async_send(out)
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_core.py", line 894, in async_send
    async_send_with_transport(
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_core.py", line 407, in async_send_with_transport
    transport.sendto(packet, (real_addr, port or _MDNS_PORT, *v6_flow_scope))
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1066, in sendto
    self._fatal_error(
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 713, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'
2022-05-02 21:49:03 WARNING (Thread-14) [pychromecast.socket_client] [Bedroom TV(192.168.0.23):8009] Error communicating with socket, resetting connection
2022-05-02 21:49:33 ERROR (Thread-14) [pychromecast.socket_client] [Bedroom TV(192.168.0.23):8009] Failed to connect to service ServiceInfo(type='host', data=('192.168.0.23', 8009)), retrying in 5.0s
2022-05-02 21:49:33 ERROR (Thread-14) [pychromecast.socket_client] [Bedroom TV(192.168.0.23):8009] Unhandled exception in worker thread, attempting reconnect
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1056, in sendto
    self._sock.sendto(data, addr)
AttributeError: 'NoneType' object has no attribute 'sendto'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/pychromecast/socket_client.py", line 538, in run
    if self.run_once(timeout=POLL_TIME_BLOCKING) == 1:
  File "/usr/local/lib/python3.9/site-packages/pychromecast/socket_client.py", line 561, in run_once
    if not self._check_connection():
  File "/usr/local/lib/python3.9/site-packages/pychromecast/socket_client.py", line 690, in _check_connection
    self.initialize_connection()
  File "/usr/local/lib/python3.9/site-packages/pychromecast/socket_client.py", line 295, in initialize_connection
    host, port, service_info = get_host_from_service(
  File "/usr/local/lib/python3.9/site-packages/pychromecast/dial.py", line 38, in get_host_from_service
    service_info = zconf.get_service_info("_googlecast._tcp.local.", service.data)
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_core.py", line 533, in get_service_info
    if info.request(self, timeout, question_type):
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_services/info.py", line 462, in request
    return bool(run_coro_with_timeout(self.async_request(zc, timeout, question_type), zc.loop, timeout))
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_utils/asyncio.py", line 97, in run_coro_with_timeout
    return asyncio.run_coroutine_threadsafe(aw, loop).result(
  File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 445, in result
    return self.__get_result()
  File "/usr/local/lib/python3.9/concurrent/futures/_base.py", line 390, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_services/info.py", line 491, in async_request
    zc.async_send(out)
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_core.py", line 894, in async_send
    async_send_with_transport(
  File "/usr/local/lib/python3.9/site-packages/zeroconf/_core.py", line 407, in async_send_with_transport
    transport.sendto(packet, (real_addr, port or _MDNS_PORT, *v6_flow_scope))
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 1066, in sendto
    self._fatal_error(
  File "/usr/local/lib/python3.9/asyncio/selector_events.py", line 713, in _fatal_error
    self._loop.call_exception_handler({
AttributeError: 'NoneType' object has no attribute 'call_exception_handler'

Home Assistant Version: 2022.4.1, using Docker
Linux version: 5.10.92-v7l+ on Raspberry Pi 4 Model B
Custom integrations:

  • eufy_security
  • hacs
  • mail_and_packages
  • sonoff
  • webrtc

Any ideas?

Thanks!