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

Incorrect exit code #232

Open
nlastovich opened this issue Dec 20, 2018 · 3 comments
Open

Incorrect exit code #232

nlastovich opened this issue Dec 20, 2018 · 3 comments

Comments

@nlastovich
Copy link

I am trying to execute two rake tasks in parallel in next way:
task :run_parallel_regression do Parallel.map(%i[thread1 thread2]) do |task| Rake::Task[task].invoke raise Parallel::Break end end

If thread1 will be finished first and the result will fail but thread2 will succeed Parallel.map exit code will be 0. What I should change in my code to make Parallel.map exit with code 1 if one of the sub-processes failed?

@grosser
Copy link
Owner

grosser commented Dec 20, 2018 via email

@nlastovich
Copy link
Author

If I will not use raise break I will get this error even if both sub-processes succeed
`rake aborted!
Parallel::DeadWorker: Parallel::DeadWorker

Caused by:
EOFError: end of file reached`

Not really sure how to implement it without rake tasks.
The interesting thing that if last finished sub-process will be failed exit code will be correct. Like it is ignoring all previously finished sub-processes

@grosser
Copy link
Owner

grosser commented Dec 20, 2018

so this works:

require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'parallel'
end

Parallel.map([1,2]) { raise }
test.rb:8:in `block in <main>': unhandled exception

... the same with a Rakefile:

require 'parallel'

task :foo do
  Parallel.map([1,2]) { raise "hi" }
end

rake foo
rake aborted!
hi

then nested rake task ... getting a little strange, but still kinda as expected:

task :bar do
  raise "hi"
end

task :foo do
  Parallel.map([1,2]) do
    Rake::Task["bar"].invoke
  end
end

rake foo
rake aborted!
Parallel::UndumpableException: RuntimeError: hi

and ordering:

task :foo do
  Parallel.map([1,2]) do |i|
    raise "hi" if i == 1
  end
end

task :bar do
  Parallel.map([1,2]) do |i|
    raise "hi" if i == 2
  end
end

both work as expected ...
so need a better example, afaik everything works fine ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants