-
Notifications
You must be signed in to change notification settings - Fork 7
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
HerokuRun#run_shell! is not threadsafe #157
Comments
That's not true. threads = []
100.times do
threads << Thread.new do
value = rand(0..10)
`exit #{value}`
{expected: value, actual: $?.exitstatus }
end
end
threads.join
output = threads.map(&:value)
output.each do |hash|
raise "oh no #{hash}" if hash[:expected] != hash[:actual]
end
# => No error or
|
That's only within a thread, right? Outside the thread you're not guaranteed that. So what about this:
Which of the two runs' |
The above code would be a bug.
In this case `$?` should be empty as `$?` is thread local and the run_multi
blocks are executed in a different thread. If it has a value, then it's
reflecting the last value in it's current thread and not from one of the
`run_multi` values.
That's why `run_multi` yields a status value in addition to the output so
that it's easier to be sure about the behavior of checking the status.
|
dzuelke
added a commit
that referenced
this issue
Jan 24, 2023
via option :return_obj => true Allows accessing e.g. process status ($? is not threadsafe, and a leaky detail of the previous underlying implementation via backticks)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This:
... will blow up with
run_multi
, because all sorts of things can happen in between the backticks and the reading of$?
.The text was updated successfully, but these errors were encountered: