parallel 1.24.0 → 1.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parallel/version.rb +1 -1
- data/lib/parallel.rb +39 -16
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8376d7bf82d796be365ef82730e51b801e672c868ce4a4c2635df4829ed5d757
|
4
|
+
data.tar.gz: b85e2f5c61cfeca064dbd59b760426ee4fca2aa351d9de06b04b819e7805ac3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e67198a4d3c6349ffc192120874addccbb092034c3e01de35da629ffb7cc3a3aae7c6c125bba35e40e270181ab6d1f7cccd7bfaada12aa1a4a325742fe9fef3b
|
7
|
+
data.tar.gz: a3a555d67029583983e89f88eec067eeef4cf39eef9fb724c9cd7dfd940ef6d5e4e8ba32c26aa04571fbfad43810a64289eb3f8b103521d15e04eb52d350eab0
|
data/lib/parallel/version.rb
CHANGED
data/lib/parallel.rb
CHANGED
@@ -24,7 +24,7 @@ module Parallel
|
|
24
24
|
attr_reader :backtrace
|
25
25
|
|
26
26
|
def initialize(original)
|
27
|
-
super
|
27
|
+
super("#{original.class}: #{original.message}")
|
28
28
|
@backtrace = original.backtrace
|
29
29
|
end
|
30
30
|
end
|
@@ -300,12 +300,12 @@ module Parallel
|
|
300
300
|
map(array, options.merge(with_index: true), &block)
|
301
301
|
end
|
302
302
|
|
303
|
-
def flat_map(
|
304
|
-
map(
|
303
|
+
def flat_map(...)
|
304
|
+
map(...).flatten(1)
|
305
305
|
end
|
306
306
|
|
307
|
-
def filter_map(
|
308
|
-
map(
|
307
|
+
def filter_map(...)
|
308
|
+
map(...).compact
|
309
309
|
end
|
310
310
|
|
311
311
|
# Number of physical processor cores on the current system.
|
@@ -328,11 +328,7 @@ module Parallel
|
|
328
328
|
end
|
329
329
|
cores.count
|
330
330
|
when /mswin|mingw/
|
331
|
-
|
332
|
-
result_set = WIN32OLE.connect("winmgmts://").ExecQuery(
|
333
|
-
"select NumberOfCores from Win32_Processor"
|
334
|
-
)
|
335
|
-
result_set.to_enum.collect(&:NumberOfCores).reduce(:+)
|
331
|
+
physical_processor_count_windows
|
336
332
|
else
|
337
333
|
processor_count
|
338
334
|
end
|
@@ -358,8 +354,35 @@ module Parallel
|
|
358
354
|
|
359
355
|
private
|
360
356
|
|
357
|
+
def physical_processor_count_windows
|
358
|
+
# Get-CimInstance introduced in PowerShell 3 or earlier: https://learn.microsoft.com/en-us/previous-versions/powershell/module/cimcmdlets/get-ciminstance?view=powershell-3.0
|
359
|
+
result = run(
|
360
|
+
'powershell -command "Get-CimInstance -ClassName Win32_Processor ' \
|
361
|
+
'| Select-Object -Property NumberOfCores"'
|
362
|
+
)
|
363
|
+
if !result || $?.exitstatus != 0
|
364
|
+
# fallback to deprecated wmic for older systems
|
365
|
+
result = run("wmic cpu get NumberOfCores")
|
366
|
+
end
|
367
|
+
if !result || $?.exitstatus != 0
|
368
|
+
# Bail out if both commands returned something unexpected
|
369
|
+
warn "guessing pyhsical processor count"
|
370
|
+
processor_count
|
371
|
+
else
|
372
|
+
# powershell: "\nNumberOfCores\n-------------\n 4\n\n\n"
|
373
|
+
# wmic: "NumberOfCores \n\n4 \n\n\n\n"
|
374
|
+
result.scan(/\d+/).map(&:to_i).reduce(:+)
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
def run(command)
|
379
|
+
IO.popen(command, &:read)
|
380
|
+
rescue Errno::ENOENT
|
381
|
+
# Ignore
|
382
|
+
end
|
383
|
+
|
361
384
|
def add_progress_bar!(job_factory, options)
|
362
|
-
if progress_options = options[:progress]
|
385
|
+
if (progress_options = options[:progress])
|
363
386
|
raise "Progressbar can only be used with array like items" if job_factory.size == Float::INFINITY
|
364
387
|
require 'ruby-progressbar'
|
365
388
|
|
@@ -388,7 +411,7 @@ module Parallel
|
|
388
411
|
results = []
|
389
412
|
exception = nil
|
390
413
|
begin
|
391
|
-
while set = job_factory.next
|
414
|
+
while (set = job_factory.next)
|
392
415
|
item, index = set
|
393
416
|
results << with_instrumentation(item, index, options) do
|
394
417
|
call_with_index(item, index, options, &block)
|
@@ -411,7 +434,7 @@ module Parallel
|
|
411
434
|
in_threads(options) do |worker_num|
|
412
435
|
self.worker_number = worker_num
|
413
436
|
# as long as there are more jobs, work on one of them
|
414
|
-
while !exception && set = job_factory.next
|
437
|
+
while !exception && (set = job_factory.next)
|
415
438
|
begin
|
416
439
|
item, index = set
|
417
440
|
result = with_instrumentation item, index, options do
|
@@ -455,7 +478,7 @@ module Parallel
|
|
455
478
|
|
456
479
|
# start
|
457
480
|
ractors.dup.each do |ractor|
|
458
|
-
if set = job_factory.next
|
481
|
+
if (set = job_factory.next)
|
459
482
|
item, index = set
|
460
483
|
instrument_start item, index, options
|
461
484
|
ractor.send [callback, item, index]
|
@@ -466,7 +489,7 @@ module Parallel
|
|
466
489
|
end
|
467
490
|
|
468
491
|
# replace with new items
|
469
|
-
while set = job_factory.next
|
492
|
+
while (set = job_factory.next)
|
470
493
|
item_next, index_next = set
|
471
494
|
done, (exception, result, item, index) = Ractor.select(*ractors)
|
472
495
|
if exception
|
@@ -669,7 +692,7 @@ module Parallel
|
|
669
692
|
end
|
670
693
|
|
671
694
|
def instrument_start(item, index, options)
|
672
|
-
return unless on_start = options[:start]
|
695
|
+
return unless (on_start = options[:start])
|
673
696
|
options[:mutex].synchronize { on_start.call(item, index) }
|
674
697
|
end
|
675
698
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
13
|
+
description:
|
14
14
|
email: michael@grosser.it
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
@@ -24,10 +24,10 @@ licenses:
|
|
24
24
|
- MIT
|
25
25
|
metadata:
|
26
26
|
bug_tracker_uri: https://github.com/grosser/parallel/issues
|
27
|
-
documentation_uri: https://github.com/grosser/parallel/blob/v1.
|
28
|
-
source_code_uri: https://github.com/grosser/parallel/tree/v1.
|
27
|
+
documentation_uri: https://github.com/grosser/parallel/blob/v1.25.0/Readme.md
|
28
|
+
source_code_uri: https://github.com/grosser/parallel/tree/v1.25.0
|
29
29
|
wiki_uri: https://github.com/grosser/parallel/wiki
|
30
|
-
post_install_message:
|
30
|
+
post_install_message:
|
31
31
|
rdoc_options: []
|
32
32
|
require_paths:
|
33
33
|
- lib
|
@@ -35,15 +35,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
35
|
requirements:
|
36
36
|
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: '2.
|
38
|
+
version: '2.7'
|
39
39
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
rubygems_version: 3.
|
46
|
-
signing_key:
|
45
|
+
rubygems_version: 3.4.10
|
46
|
+
signing_key:
|
47
47
|
specification_version: 4
|
48
48
|
summary: Run any kind of code in parallel processes
|
49
49
|
test_files: []
|