Uh oh!
There was an error while loading. Please reload this page.
gh-124621: Emscripten: Add support for async input devices - #136822
Merged
Conversation
hoodmane
commented
Jul 19, 2025
ContributorAuthor
!buildbot emscripten |
bedevere-bot
commented
Jul 19, 2025
🤖 New build scheduled with the buildbot fleet by @hoodmane for commit 3d573d5 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F136822%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
This is useful for implementing proper `input()`. It requires the JavaScript engine to support the wasm JSPI spec which is now stage 4. It is supported on Chrome since version 137 and on Firefox and node behind a flag. We override the `__wasi_fd_read()` syscall with our own variant that checks for a readAsync operation. If it has it, we use our own async variant of `fd_read()`, otherwise we use the original `fd_read()`. We also add a variant of `FS.createDevice()` called `FS.createAsyncInputDevice()`. Finally, if JSPI is available, we wrap the `main()` symbol with `WebAssembly.promising()` so that we can stack switch from `fd_read()`. If JSPI is not available, attempting to read from an AsyncInputDevice will raise an `OSError`.
hoodmaneforce-pushed
the
emscripten-async-input-device
branch
from
July 19, 2025 14:26
3d573d5 to
7d0e709CompareUh oh!
There was an error while loading. Please reload this page.
hoodmane
commented
Jul 19, 2025
ContributorAuthor
Oops this caused some test failures. Fix incoming. |
hoodmane added a commit
to hoodmane/cpython
that referenced
this pull request
Jul 19, 2025
…handling Introduced in pythonGH-136822. If the fd is already closed, `SYSCALLS.getStreamFromFD()` throws an error. We need to catch it and discard it. The `__wasi_fd_read_orig()` fallback will use it to set errno.
hoodmane added a commit
to hoodmane/cpython
that referenced
this pull request
Jul 19, 2025
…handling Introduced in pythonGH-136822. If the fd is already closed, `SYSCALLS.getStreamFromFD()` throws an error. We need to catch it and discard it. The `__wasi_fd_read_orig()` fallback will use it to set errno.
hoodmane added a commit
to hoodmane/cpython
that referenced
this pull request
Jul 19, 2025
…handling Introduced in pythonGH-136822. If the fd is already closed, `SYSCALLS.getStreamFromFD()` throws an error. We need to catch it and discard it. The `__wasi_fd_read_orig()` fallback will use it to set errno.
hoodmane added a commit
to hoodmane/cpython
that referenced
this pull request
Jul 19, 2025
…handling Introduced in pythonGH-136822. If the fd is already closed, `SYSCALLS.getStreamFromFD()` throws an error. We need to catch it and discard it. The `__wasi_fd_read_orig()` fallback will use it to set errno.
miss-islington pushed a commit
to miss-islington/cpython
that referenced
this pull request
Jul 21, 2025
…honGH-136822) This is useful for implementing proper `input()`. It requires the JavaScript engine to support the wasm JSPI spec which is now stage 4. It is supported on Chrome since version 137 and on Firefox and node behind a flag. We override the `__wasi_fd_read()` syscall with our own variant that checks for a readAsync operation. If it has it, we use our own async variant of `fd_read()`, otherwise we use the original `fd_read()`. We also add a variant of `FS.createDevice()` called `FS.createAsyncInputDevice()`. Finally, if JSPI is available, we wrap the `main()` symbol with `WebAssembly.promising()` so that we can stack switch from `fd_read()`. If JSPI is not available, attempting to read from an AsyncInputDevice will raise an `OSError`. (cherry picked from commit 7ae4749) Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
GH-136935 is a backport of this pull request to the 3.14 branch. |
ambv pushed a commit
that referenced
this pull request
Jul 22, 2025
…-136822) (GH-136935) This is useful for implementing proper `input()`. It requires the JavaScript engine to support the wasm JSPI spec which is now stage 4. It is supported on Chrome since version 137 and on Firefox and node behind a flag. We override the `__wasi_fd_read()` syscall with our own variant that checks for a readAsync operation. If it has it, we use our own async variant of `fd_read()`, otherwise we use the original `fd_read()`. We also add a variant of `FS.createDevice()` called `FS.createAsyncInputDevice()`. Finally, if JSPI is available, we wrap the `main()` symbol with `WebAssembly.promising()` so that we can stack switch from `fd_read()`. If JSPI is not available, attempting to read from an AsyncInputDevice will raise an `OSError`. (cherry picked from commit 7ae4749) Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
taegyunkim pushed a commit
to taegyunkim/cpython
that referenced
this pull request
Aug 4, 2025
…honGH-136822) This is useful for implementing proper `input()`. It requires the JavaScript engine to support the wasm JSPI spec which is now stage 4. It is supported on Chrome since version 137 and on Firefox and node behind a flag. We override the `__wasi_fd_read()` syscall with our own variant that checks for a readAsync operation. If it has it, we use our own async variant of `fd_read()`, otherwise we use the original `fd_read()`. We also add a variant of `FS.createDevice()` called `FS.createAsyncInputDevice()`. Finally, if JSPI is available, we wrap the `main()` symbol with `WebAssembly.promising()` so that we can stack switch from `fd_read()`. If JSPI is not available, attempting to read from an AsyncInputDevice will raise an `OSError`.
Agent-Hellboy pushed a commit
to Agent-Hellboy/cpython
that referenced
this pull request
Aug 19, 2025
…honGH-136822) This is useful for implementing proper `input()`. It requires the JavaScript engine to support the wasm JSPI spec which is now stage 4. It is supported on Chrome since version 137 and on Firefox and node behind a flag. We override the `__wasi_fd_read()` syscall with our own variant that checks for a readAsync operation. If it has it, we use our own async variant of `fd_read()`, otherwise we use the original `fd_read()`. We also add a variant of `FS.createDevice()` called `FS.createAsyncInputDevice()`. Finally, if JSPI is available, we wrap the `main()` symbol with `WebAssembly.promising()` so that we can stack switch from `fd_read()`. If JSPI is not available, attempting to read from an AsyncInputDevice will raise an `OSError`.
kumaraditya303 pushed a commit
to miss-islington/cpython
that referenced
this pull request
Sep 9, 2025
…es (pythonGH-136822) (pythonGH-136935) This is useful for implementing proper `input()`. It requires the JavaScript engine to support the wasm JSPI spec which is now stage 4. It is supported on Chrome since version 137 and on Firefox and node behind a flag. We override the `__wasi_fd_read()` syscall with our own variant that checks for a readAsync operation. If it has it, we use our own async variant of `fd_read()`, otherwise we use the original `fd_read()`. We also add a variant of `FS.createDevice()` called `FS.createAsyncInputDevice()`. Finally, if JSPI is available, we wrap the `main()` symbol with `WebAssembly.promising()` so that we can stack switch from `fd_read()`. If JSPI is not available, attempting to read from an AsyncInputDevice will raise an `OSError`. (cherry picked from commit 7ae4749) Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is useful for implementing proper
input(). It requires the JavaScript engine to support the wasm JSPI spec which is now stage 4. It is supported on Chrome since version 137 and on Firefox and node behind a flag.We override the
__wasi_fd_read()syscall with our own variant that checks for a readAsync operation. If it has it, we use our own async variant offd_read(), otherwise we use the originalfd_read(). We also add a variant ofFS.createDevice()calledFS.createAsyncInputDevice().Finally, if JSPI is available, we wrap the
main()symbol withWebAssembly.promising()so that we can stack switch fromfd_read(). If JSPI is not available, attempting to read from an AsyncInputDevice will raise anOSError.