Skip to content
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

spawn: permit using IOBuffer as stdout #52461

Merged
merged 1 commit into from
Dec 13, 2023
Merged

spawn: permit using IOBuffer as stdout #52461

merged 1 commit into from
Dec 13, 2023

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Dec 8, 2023

People expect to use this (the docs even almost even suggested it at some point), so it is better to make it work as expected (and better than they can emulate) than to criticize their choices.

Also fix a few regressions and handling mistakes in setup_stdios:

  • Improve inference for string operations #44500 tried to store a Redirectable into a SpawnIO, dropping FileRedirect
  • CmdRedirect did not allocate a ProcessChain, so it wouldd call setup_stdio then call setup_stdios on the result of that, which is strongly discouraged as setup_stdio(s) should only be called once
  • BufferStream was missing check_open calls before writing, and ignored Base.reseteof as a possible means of resuming writing after closewrite sends a shutdown message. Currently this fix is disabled because Pkg seems like a bit of a disaster with IO mismanagement.
  • Add closewrite to more methods, and document it.

Fixes #39311
Fixes #49234
Closes #49233
Closes #46768

@vtjnash vtjnash added the io Involving the I/O subsystem: libuv, read, write, etc. label Dec 8, 2023
@vtjnash vtjnash changed the title spawn: permit using IOBuffer at stdout spawn: permit using IOBuffer as stdout Dec 8, 2023
NEWS.md Show resolved Hide resolved
People expect to use this (the docs even almost even suggested it at
some point), so it is better to make it work as expected (and better
than they can emulate) than to criticize their choices.

Also fix a few regressions and handling mistakes in setup_stdios:
 - #44500 tried to store a Redirectable into a SpawnIO, dropping FileRedirect
 - CmdRedirect did not allocate a ProcessChain, so it wouldd call
   setup_stdio then call setup_stdios on the result of that, which is
   strongly discouraged as setup_stdio(s) should only be called once
 - BufferStream was missing `check_open` calls before writing, and
   ignored `Base.reseteof` as a possible means of resuming writing after
   `closewrite` sends a shutdown message. Currently this fix is disabled
   because Pkg seems like a bit of a disaster with IO mismanagement.
 - Add `closewrite` to more methods, and document it.

Fixes #39311
Fixes #49234
Closes #49233
Closes #46768
@vtjnash
Copy link
Member Author

vtjnash commented Dec 12, 2023

This should avoid the test bug introduced by #52217 (this bug was noticed also in the CI run before merging #52217 (comment) but ignored there) that caused this recent CI run to fail: https://buildkite.com/julialang/julia-master/builds/31117#018c5b9f-5171-48a7-95a8-186282ca9fef

@vtjnash vtjnash merged commit 282e466 into master Dec 13, 2023
4 of 7 checks passed
@vtjnash vtjnash deleted the jn/spawn-IOBuffer branch December 13, 2023 14:54
vtjnash added a commit that referenced this pull request Dec 14, 2023
@@ -73,6 +73,14 @@ New library features
write the output to a stream rather than returning a string ([#48625]).
* `sizehint!(s, n)` now supports an optional `shrink` argument to disable shrinking ([#51929]).
* New function `Docs.hasdoc(module, symbol)` tells whether a name has a docstring ([#52139]).
* Passing an IOBuffer as a stdout argument for Process spawn now works as
expected, synchronized with `wait` or `success`, so a `Base.BufferStream` is
no longer required there for correctness to avoid data-races ([#TBD]).
Copy link
Member

Choose a reason for hiding this comment

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

Whoops — "TBD" should have been updated.

@stevengj stevengj mentioned this pull request Dec 28, 2023
jishnub pushed a commit that referenced this pull request Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
io Involving the I/O subsystem: libuv, read, write, etc.
Projects
None yet
3 participants