A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: make WASM `as_completed` timeout deterministic (#9891)
Péter Gyarmatid16962dcb4f2
diff --git a/tests/_runtime/test_wasm_futures.py b/tests/_runtime/test_wasm_futures.pyindex bf72f3ec16..fbcc351f72 100644--- a/tests/_runtime/test_wasm_futures.py+++ b/tests/_runtime/test_wasm_futures.py@@ -6,11 +6,11 @@ import concurrent.futuresimport contextvarsimport functoolsimport threading-import timefrom typing import Any, castimport pytest+from marimo._runtime._wasm._concurrency import _futures as wasm_futuresfrom marimo._runtime._wasm._concurrency._futures import AsyncioFuturefrom marimo._runtime._wasm._concurrency._install import (install_wasm_concurrency_shims,@@ -549,19 +549,29 @@ def test_wasm_as_completed_timeout_zero_yields_done_futures() -> None:unpatch()-def test_wasm_as_completed_deadline_excludes_late_completions() -> None:+def test_wasm_as_completed_deadline_excludes_late_completions(+ monkeypatch: pytest.MonkeyPatch,+) -> None:with mock_pyodide():unpatch = install_wasm_concurrency_shims()first: concurrent.futures.Future[str] = AsyncioFuture()second: concurrent.futures.Future[str] = AsyncioFuture()+ timeout = 0.001+ now = 0.0++ class _FakeTime:+ def monotonic(self) -> float:+ return now++ monkeypatch.setattr(wasm_futures, "time", _FakeTime())try:first.set_result("first")iterator = concurrent.futures.as_completed(- [first, second], timeout=0.001+ [first, second], timeout=timeout)assert next(iterator) is first- time.sleep(0.01)+ now = timeout * 2second.set_result("late")with pytest.raises(concurrent.futures.TimeoutError):