Skip to content

PyScript makes blocking file system calls inside event loop (os.scandir) #850

@shashchatter

Description

@shashchatter

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

  1. Create a PyScript with glob.glob() in an async function
  2. Call the script
  3. 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")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions