Skip to content

gh-146416: Emscripten: Improve standard stream handling in node_entry.mjs#146417

Open
hoodmane wants to merge 6 commits intopython:mainfrom
hoodmane:streams
Open

gh-146416: Emscripten: Improve standard stream handling in node_entry.mjs#146417
hoodmane wants to merge 6 commits intopython:mainfrom
hoodmane:streams

Conversation

@hoodmane
Copy link
Copy Markdown
Contributor

@hoodmane hoodmane commented Mar 25, 2026

@vstinner
Copy link
Copy Markdown
Member

The test suite fails on Emscripten with nodeFsync is not defined: https://github.com/python/cpython/actions/runs/23545540285/job/68544804717?pr=146417


0:00:13 load avg: 0.10 [ 78/502] test.test_os.test_os
file:///home/runner/work/cpython/cpython/cross-build/wasm32-emscripten/build/python/streams.mjs:189
    nodeFsync(this.nodeStream.fd);
    ^

ReferenceError: nodeFsync is not defined
    at NodeWriter.fsync (file:///home/runner/work/cpython/cpython/cross-build/wasm32-emscripten/build/python/streams.mjs:189:5)
    at Object.fsync (file:///home/runner/work/cpython/cpython/cross-build/wasm32-emscripten/build/python/streams.mjs:136:11)
    at Object.close (file:///home/runner/work/cpython/cpython/cross-build/wasm32-emscripten/build/python/streams.mjs:131:23)
    at Object.close (file:///home/runner/work/cpython/cpython/cross-build/wasm32-emscripten/build/python/python.mjs:1:71931)
    at _fd_close (file:///home/runner/work/cpython/cpython/cross-build/wasm32-emscripten/build/python/python.mjs:1:271594)
    at wasm://wasm/02b6ddae:wasm-function[12183]:0x69a8ab
    at wasm://wasm/02b6ddae:wasm-function[8357]:0x498ddf
    at wasm://wasm/02b6ddae:wasm-function[1978]:0x1e167a
    at wasm://wasm/02b6ddae:wasm-function[803]:0x18e943
    at wasm://wasm/02b6ddae:wasm-function[3473]:0x2ad92d

Node.js v24.14.0
Error: Process completed with exit code 1.

* https://github.com/emscripten-core/emscripten/blob/1aa7fb531f11e11e7ae49b75a24e1a8fe6fa4a7d/src/lib/libtty.js?plain=1#L104-L114
*
* Ideally some version of this should go upstream to Emscripten since it is not
* in any way specific to Python. But I haven't gotten around to it yet.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you specify who is "I" in this sentence?

Suggested change
* in any way specific to Python. But I haven't gotten around to it yet.
* in any way specific to Python. But I (Hood) haven't gotten around to it yet.

// an O_NONBLOCK file descriptor. Synchronously sleep for 100ms as
// requested by EAGAIN and try again. In case for some reason we fail to
// sleep, propagate the error (it will turn into an EOFError).
if (syncSleep(100)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100 ms sounds high to me. What about 10 ms?

}
if (nbytes === undefined) {
// Prevent an infinite loop caused by incorrect code that doesn't return a
// value
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// value
// value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants