-
Notifications
You must be signed in to change notification settings - Fork 509
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
Tests output to global stdout #597
Comments
Also note the reason given on that unstable feature: "this function may disappear completely or be replaced with a more general mechanism", with no tracking issue. Even with that, it's complicated. We would have to update this every time we steal a job, including when a job is pulled from the global injector queue (coming from outside the threadpool). Save the old value, clone the remote value (how?) to set locally, then restore the saved value on return. Writes would have to be synchronized too, because the handle as-is only requires |
Within a rayon::scope(|_| { some_vec.par_iter().for_each(|i| i.method();) }) |
A scope does not imply a separate threadpool. Calling |
For reference, there's also rust-lang/rust#42474. But as you noted there, they probably couldn't deal with a threadpool like Rayon automatically. |
I guess an example would be best. Basically, it'd be nice to be able to do: #[test]
fn my_test() {
// This API doesn't exist either.
// This code could be wrapped up in a `test_pool()` utility function though.
let output = std::stdio::get_stdio();
let pool = rayon::ThreadPoolBuilder::new().with_output(&output).build();
pool.install(|| my_rayon_using_fn());
} Would that |
With some appropriate get/set methods from |
I think a start handler could also set the output, without any changes required in Rayon. |
When running a test with
cargo test
which usesrayon
, workers which useprint!
(e.g., from a stub logging implementation) skip the test-local output and don't get buffered/hidden/etc.Is there some way using the
scope
API to set the output handler for the thread pool in use? I'm guessing something new would need to be added. Note that it would seem to require theset_stdio
unstable feature, but I'm interested in having some way inrayon
available once it is stable.The text was updated successfully, but these errors were encountered: