Skip to content

Commit

Permalink
Ensure not to use old concurrent-ruby
Browse files Browse the repository at this point in the history
It seems that some users encounter with a negative values issue of
`Concurrent.available_processor_count`.

#349 (comment)

To avoid the issue, this PR ensure not to use old `concurrent-ruby`.
This PR also removes considering of `NoMethodError` because we can
assume to use `available_processor_count` always.
  • Loading branch information
y-yagi committed Aug 16, 2024
1 parent ab06d9e commit 43c9805
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/parallel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -697,9 +697,10 @@ def instrument_start(item, index, options)
end

def available_processor_count
gem 'concurrent-ruby', '>= 1.3.4'
require 'concurrent-ruby'
Concurrent.available_processor_count.floor
rescue LoadError, NoMethodError
rescue LoadError
require 'etc'
Etc.nprocessors
end
Expand Down

0 comments on commit 43c9805

Please sign in to comment.