You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To be concrete: support for the emscripten build of CPython and pyodide.
It would be really cool :3
I mean, it would also indicate that our basic IO manager protocol is good enough to stabilize if we can implement such a strange architecture.
I'm not sure how testing would work nor whether anyone would use it. Also I'm not sure concretely what we can support:
obviously we can manage sleeping and rescheduling
sockets isn't possible AFAIK? I guess there's those WASI things.
does pyodide provide a virtual file system or something? Maybe WASI does?
Unless... Trio already works due to some compatibility things done by CPython? I am 95% it doesn't work though. At least I should figure out how tests would work.
>>> import micropip>>> await micropip.install("trio")>>> import trioTraceback (most recent call last): File "<console>", line 1, in <module> File "/lib/python3.13/site-packages/trio/__init__.py", line 22, in <module> from ._core import TASK_STATUS_IGNORED as TASK_STATUS_IGNORED # isort: split ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/lib/python3.13/site-packages/trio/_core/__init__.py", line 21, in <module> from ._local import RunVar, RunVarToken File "/lib/python3.13/site-packages/trio/_core/_local.py", line 9, in <module> from . import _run File "/lib/python3.13/site-packages/trio/_core/_run.py", line 3004, in <module> raise NotImplementedError("unsupported platform")NotImplementedError: unsupported platform
So kind of success so far, can install at least, but needs work of course
Maybe you just want to run a trio event loop on its own as a first step, but it's worth mentioning that pyodide integrates asyncio into the JavaScript event loop here. That allows e.g. JavaScript to await a Python task.
I would expect we don't need any special support in pyodide because of trio.lowlevel.wait_task_rescheduled (for Python awaiting JS) and the other way around is probably simple to do with plain JS promises.
So kind of success so far, can install at least, but needs work of course
Yeah, I think that means we don't have an IO manager for it.
Unfortunately, there doesn't seem to be a way to suspend execution. This makes this entirely impractical, since it means you won't be able to reschedule from e.g. promises. It's possible to work around this, but that would mean no return value from trio.run (note: it's synchronous!).
The best alternate implementation probably involves spitting a signal at the program like in https://pyodide.org/en/stable/usage/keyboard-interrupts.html but that's pyodide specific. This is all just supposed to be whimsical so I don't really think it's worth tying ourselves to a particular implementation for practical results.
Activity
CoolCat467 commentedon Aug 4, 2025
On https://pyodide.org/en/stable/console.html (had to hack the script to use v0.28.0 instead of 0.28.1)
So kind of success so far, can install at least, but needs work of course
davidbrochart commentedon Aug 4, 2025
Maybe you just want to run a trio event loop on its own as a first step, but it's worth mentioning that pyodide integrates asyncio into the JavaScript event loop here. That allows e.g. JavaScript to await a Python task.
A5rocks commentedon Aug 7, 2025
I would expect we don't need any special support in pyodide because of
trio.lowlevel.wait_task_rescheduled(for Python awaiting JS) and the other way around is probably simple to do with plain JS promises.Yeah, I think that means we don't have an IO manager for it.
A5rocks commentedon May 23, 2026
I made a prototype version. See https://github.com/A5rocks/trio/tree/wasm-trio, you can run it via
uv run -m build && uv run -m http.server, then open http://localhost:8000 and try something like this in the console:Unfortunately, there doesn't seem to be a way to suspend execution. This makes this entirely impractical, since it means you won't be able to reschedule from e.g. promises. It's possible to work around this, but that would mean no return value from
trio.run(note: it's synchronous!).The best alternate implementation probably involves spitting a signal at the program like in https://pyodide.org/en/stable/usage/keyboard-interrupts.html but that's pyodide specific. This is all just supposed to be whimsical so I don't really think it's worth tying ourselves to a particular implementation for practical results.