-
Notifications
You must be signed in to change notification settings - Fork 6k
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
[core] Fix std::flush with istream::readsome
#50248
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0953813
pipe readsome
dentiny f25d458
close stream fd
dentiny 0a93a3f
Merge branch 'master' into hjiang/pipe-readsome
dentiny 1e025d9
integrate with newliner sink
dentiny 0d5ad28
doc on close
dentiny 9d2ebc3
fix clear and new test
dentiny be1b38f
no need newliner handle
dentiny fb0af5a
ray config
dentiny 3d4745f
restore
dentiny db87225
Merge branch 'master' into hjiang/pipe-readsome
dentiny e2bfd98
use scoped env setter
dentiny babd0bb
scoped env
dentiny 3d79046
Merge branch 'master' into hjiang/pipe-readsome
dentiny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2025 The Ray Authors. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// This test case only checks whether stream redirection process could exit normally. | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <chrono> | ||
#include <iostream> | ||
#include <thread> | ||
|
||
#include "ray/common/test/testing.h" | ||
#include "ray/util/filesystem.h" | ||
#include "ray/util/stream_redirection_utils.h" | ||
#include "ray/util/util.h" | ||
|
||
namespace ray { | ||
|
||
namespace { | ||
constexpr std::string_view kLogLine1 = "hello\n"; | ||
constexpr std::string_view kLogLine2 = "world"; | ||
} // namespace | ||
|
||
TEST(LoggingUtilTest, RedirectStderr) { | ||
const std::string test_file_path = absl::StrFormat("%s.err", GenerateUUIDV4()); | ||
|
||
// Works via `dup`, so have to execute before we redirect via `dup2` and close stderr. | ||
testing::internal::CaptureStderr(); | ||
|
||
// Redirect stderr for testing, so we could have stdout for debugging. | ||
StreamRedirectionOption opts; | ||
opts.file_path = test_file_path; | ||
opts.tee_to_stderr = true; | ||
RedirectStderr(opts); | ||
|
||
std::cerr << kLogLine1 << std::flush; | ||
std::cerr << kLogLine2 << std::flush; | ||
|
||
// TODO(hjiang): Current implementation is flaky intrinsically, sleep for a while to | ||
// make sure pipe content has been read over to spdlog. | ||
std::this_thread::sleep_for(std::chrono::seconds(2)); | ||
FlushOnRedirectedStderr(); | ||
|
||
// Make sure flush hook works fine and process terminates with no problem. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we are not checking anything here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See documentation above.
|
||
} | ||
|
||
} // namespace ray |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we decouple
RedirectStream
withatexit()
so that we can test better and don't need to create a file for each test.Ideally we can manually call
SyncOnStreamRedirection
to close the redirection.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That way you need to return redirection handler to the caller? Or return the exit terminator.