custom-components / pyscript

Pyscript adds rich Python scripting to HASS
Apache License 2.0
874 stars 46 forks source link

HA Blocked - Detected blocking call to sleep inside the event loop #423

Closed marcoCasamento closed 1 year ago

marcoCasamento commented 1 year ago

Sometimes HA become unresponsive until I manually restart it, and I found in the log many lines like the following one:

Logger: homeassistant.util.async Source: util/async.py:180 First occurred: 19:24:49 (241 occurrences) Last logged: 19:28:58

Detected blocking call to sleep inside the event loop. This is causing stability issues. Please report issue to the custom integration author for pyscript doing blocking calls at custom_components/pyscript/eval.py, line 1906: return func(*args, **kwargs)

Is there something I can do to debug the issue ?

sr-as2 commented 1 year ago

Hi, i'm having the same issue. It slow down interface and i cannot use HA anymore since i reboot

craigbarratt commented 1 year ago

It's almost certainly because your pyscript code is calling time.sleep() or some similar function, either directly or inside a package that your code is calling.

All pyscript code must be non-blocking, and async versions of functions should be used in place of functions that would block (eg: http requests etc). There is a function task.sleep() that can be safely used instead of time.sleep(); see the docs.

sr-as2 commented 1 year ago

Ok thanks, i find my problem: https://community.home-assistant.io/t/sync-your-alexa-todoist-shopping-list-to-the-home-assistant-shopping-list/274277/102