-
Notifications
You must be signed in to change notification settings - Fork 47
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
Detected blocking call #619
Comments
Bug Report: Blocking Call Detected in Pyscript Integration Description: Logger: Source: First Occurrence: Last Occurrence: Details: |
I have the same issue. This is my code that causes that blocking call warning:
|
This is because you are making file system calls (eg, os.scandir), which can block. Pyscript runs in the main event loop so you cannot call functions that block. There are two solutions:
|
Hi there,as I am not a dev, I don't understand a single word 😁I hope, some skilled dev reads this and can help/fix this.Using the onboard backup function should work, I guess.Thanks for checkimg this topic.Best regardsFreundliche Grüße, FrankAm 27.11.2024 um 19:55 schrieb Craig Barratt ***@***.***>:
This is because you are making file system calls (eg, os.scandir), which can block. Pyscript runs in the main event loop so you cannot call functions that block. There are two solutions:
use async versions of file system calls, eg, aiopath.
use task.executor to run the blocking code outside the main event loop. See the documentation.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Thanks, I was under the impression that pyscripts were running asynchronous by design. Will look into your leads and learn |
Today I got the following warning:
2024-07-15 08:06:25.171 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to scandir with args (b'/config/pyscript',) inside the event loop by custom integration 'pyscript' at custom_components/pyscript/init.py, line 335: observer.start() (offender: , line 366: ?), please create a bug report at https://github.com/custom-components/pyscript/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#scandir
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/usr/src/homeassistant/homeassistant/main.py", line 223, in
sys.exit(main())
File "/usr/src/homeassistant/homeassistant/main.py", line 209, in main
exit_code = runner.run(runtime_conf)
File "/usr/src/homeassistant/homeassistant/runner.py", line 190, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever
self._run_once()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once
handle._run()
File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/config/custom_components/pyscript/init.py", line 335, in hass_started
observer.start()
The text was updated successfully, but these errors were encountered: