PyScript makes blocking calls to os.scandir() (via glob.glob()) directly inside async functions, which violates Home Assistant's async event loop safety.
Home Assistant's built-in async loop detector warns users about this and specifically instructs them to create a bug report in this repository:
"Detected blocking call to scandir inside the event loop by custom integration 'pyscript'... please create a bug report at https://github.com/custom-components/pyscript/issues"
Steps to Reproduce
- Create a PyScript with
glob.glob() in an async function
- Call the script
- Check logs for blocking call warning
Minimal Reproduction
import glob
@pyscript.service
async def test_blocking_scandir():
files = glob.glob("/config/00_automations/*")
log.info(f"Found {len(files)} files")
PyScript makes blocking calls to
os.scandir()(viaglob.glob()) directly inside async functions, which violates Home Assistant's async event loop safety.Home Assistant's built-in async loop detector warns users about this and specifically instructs them to create a bug report in this repository:
Steps to Reproduce
glob.glob()in an async functionMinimal Reproduction