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

Ruby 3.5 to drop win32ole #345

Closed
Earlopain opened this issue Jun 5, 2024 · 2 comments · Fixed by #346
Closed

Ruby 3.5 to drop win32ole #345

Earlopain opened this issue Jun 5, 2024 · 2 comments · Fixed by #346

Comments

@Earlopain
Copy link
Contributor

Ruby is continuing its path of requiring more gems to be specified. win32ole is next on the list (among others) and will start warning in Ruby 3.4: ruby/ruby@f365bef

Usage is here, to get the number of cores on windows:

parallel/lib/parallel.rb

Lines 331 to 336 in f66f105

require 'win32ole'
result_set = WIN32OLE.connect("winmgmts://").ExecQuery(
"select NumberOfCores from Win32_Processor"
)
result_set.to_enum.collect(&:NumberOfCores).reduce(:+)
else

Something like the following may be a suitable replacement:

IO.popen("wmic cpu get NumberOfCores", &:read).scan(/\d+/).map(&:to_i).reduce(:+)

Output of that command:
NumberOfCores \n\n4 \n\n\n\n

I have also openend the same report on concurrent-ruby at ruby-concurrency/concurrent-ruby#1048 if you are interested. Both implementations for this are basically the same.

@grosser
Copy link
Owner

grosser commented Jun 5, 2024

awesome, thx for the heads up!
I'll wait for concurrent-ruby to address this since they got more manpower :)

@Earlopain
Copy link
Contributor Author

I openend ruby-concurrency/concurrent-ruby#1051 if you have some feedback

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

Successfully merging a pull request may close this issue.

2 participants