Skip to content

running time.sleep() in guest potentially blocks session.run() indefinitely #10

Description

@silcowitz

Thanks for this cool project.

If I run this code, session.run doesn't return after 1 second, it returns after the full 3 seconds with an exception. Is this intended? Im hitting this problem in a much more complicated use-case but I boiled (some of it) down to this example. This is obviously contrived but adversarial code could block the sandbox like this for a long time, potentially indefinitely.

from micropython_wasm import MicroPythonSession
import time

session = MicroPythonSession(wall_timeout_seconds=1)

started = time.monotonic()
try:
    print("starting")
    session.run(
        "import time\n"
        "time.sleep(3)\n"
        "print(\"done\")\n")
    print("returned")
finally:
    elapsed = time.monotonic() - started
    print(f"elapsed={elapsed:.1f}s")
    session.close()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions