epson_projector
epson_projector copied to clipboard
Switch to serial_asyncio_fast
trafficstars
I got the warning/error below in the HomeAssistant logs.
Traceback (most recent call last):
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.12/site-packages/serial_asyncio/__init__.py", line 417, in _call_connection_lost
self._serial.close()
File "/usr/local/lib/python3.12/site-packages/serial/urlhandler/protocol_socket.py", line 104, in close
time.sleep(0.3)
File "/usr/src/homeassistant/homeassistant/util/loop.py", line 192, in protected_loop_func
raise_for_blocking_call(
File "/usr/src/homeassistant/homeassistant/util/loop.py", line 96, in raise_for_blocking_call
raise RuntimeError( # noqa: TRY200
RuntimeError: Caught blocking call to sleep with args (0.3,) in /usr/local/lib/python3.12/site-packages/serial/urlhandler/protocol_socket.py, line 104: time.sleep(0.3) inside the event loop; This is causing stability issues. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#sleep
As mentioned on the linked page this is caused by serial_asyncio and can be resolved by switching to serial_asyncio_fast which among other fixes also solves this issue.
This PR does the switch.
Tested with the test_serial.py from the repo and works fine.
I intend to do the follow up PR in Home Assistant when a release with this change is made.