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

Switch to serial_asyncio_fast #22

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

mvdwetering
Copy link

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.

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