New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emscripten event loop? #93596
Comments
So are you asking for asyncio to gain an emscripten-based event loop? What would that look like? Would it require exposing JS-level hooks to tie into the JS event loop? If so, how would that operate since I thought there wasn't a desire to bring in And I assume such a loop could live on PyPI without issue, so having such a thing in the stdlib is a "nice to have" more than a "technically not possible any other way"? |
I would rewrite the Pyodide event to avoid
Without Pyodide, it might be difficult to dynamically link the event loop. If This is a convenience thing but it may make the difference in terms of complexity to be able to run stuff in CI: the non-asyncio PyO3 tests work only using the standard library. The async tests assume the standard library will contain a working event loop. To get to loading wheels from PyPI adds a significant amount of complexity beyond "just link libpython.a". It's desirable to keep CI builds simple and probably rather than pulling in enough stuff to load a wheel it would be better to xfail async tests. |
I guess because PyO3 is statically linked I could make an event loop in a separate repo, clone it, and add it to |
My key concern is Empscripten/WASI isn't even a tier 3 language for CPython, let alone something like a tier 2 language where it starts to make sense to try and get a WASM-based event loop working for the platform. And with the asyncio test suite being notoriously flaky, adding anything there makes me worry. 😅 |
I have good news and bad news for you. The asyncio tests are not working on wasm32-emscripten anyway because |
I think it is too early for an emscripten event loop in stdlib. Since emscripten does not support some(most?) of the socket functions, it would require a lot of As Brett said, emscripten is not even a tier 3 platform so adding it to stdlib is unlikely, however you can work on it in a fork. |
I think it would be helpful for the wasm/emscripten ecosystem to have an event loop as part of CPython. For example, recently we added Emscripten to the PyO3 CI PyO3/pyo3#2436. The asyncio tests have to be xfailed because there is no event loop. I would be willing to contribute one if there is interest.
The biggest drawback is that
asyncio.run_until_complete
and similar blocking APIs don't work, so it's different enough that many tests may not just work. On the other hand, I think that Pyodide's event loop has proven to be a very important feature.@tiran @brettcannon
The text was updated successfully, but these errors were encountered: