parallel 1.16.1 → 1.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/parallel/processor_count.rb +3 -5
- data/lib/parallel/version.rb +1 -1
- data/lib/parallel.rb +21 -11
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da9740ffe51b7c2867eb4a51b9477aa0195c475ba27342793a3a6f7aa209b9ab
|
4
|
+
data.tar.gz: cc98ae0e7c35557d064abf720263258a0340c30ec405d30342636f1667fc32c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c71c1888523f4d9ed6c3050c8c06d425330d955c5bc30be331f93a46b346984b489ba78ded574bb7197a3c9ac34076924e90d21765085d6fdfc5dce1d0ef27f
|
7
|
+
data.tar.gz: 458976b6feaf2e34201ffb06a855940581eafe97306c638ccb2e583f8ed975a174a56e482a84e7d6a2c2a806ee94cf23adf66d43fc48b133433d275fea872d58
|
@@ -1,16 +1,14 @@
|
|
1
1
|
require 'etc'
|
2
2
|
|
3
3
|
module Parallel
|
4
|
+
# TODO: inline this method into parallel.rb and kill physical_processor_count in next major release
|
4
5
|
module ProcessorCount
|
5
|
-
# Number of processors seen by the OS
|
6
|
+
# Number of processors seen by the OS, used for process scheduling
|
6
7
|
def processor_count
|
7
|
-
@processor_count ||=
|
8
|
-
Etc.nprocessors
|
9
|
-
end
|
8
|
+
@processor_count ||= Integer(ENV['PARALLEL_PROCESSOR_COUNT'] || Etc.nprocessors)
|
10
9
|
end
|
11
10
|
|
12
11
|
# Number of physical processor cores on the current system.
|
13
|
-
#
|
14
12
|
def physical_processor_count
|
15
13
|
@physical_processor_count ||= begin
|
16
14
|
ppc = case RbConfig::CONFIG["target_os"]
|
data/lib/parallel/version.rb
CHANGED
data/lib/parallel.rb
CHANGED
@@ -44,10 +44,9 @@ module Parallel
|
|
44
44
|
|
45
45
|
class Worker
|
46
46
|
attr_reader :pid, :read, :write
|
47
|
-
attr_accessor :thread
|
47
|
+
attr_accessor :thread
|
48
48
|
def initialize(read, write, pid)
|
49
49
|
@read, @write, @pid = read, write, pid
|
50
|
-
@lap = 0
|
51
50
|
end
|
52
51
|
|
53
52
|
def stop
|
@@ -202,13 +201,20 @@ module Parallel
|
|
202
201
|
|
203
202
|
class << self
|
204
203
|
def in_threads(options={:count => 2})
|
205
|
-
|
206
|
-
|
207
|
-
|
204
|
+
Thread.handle_interrupt(Exception => :never) do
|
205
|
+
begin
|
206
|
+
threads = []
|
207
|
+
count, _ = extract_count_from_options(options)
|
208
|
+
count.times do |i|
|
209
|
+
threads << Thread.new { yield(i) }
|
210
|
+
end
|
211
|
+
Thread.handle_interrupt(Exception => :immediate) do
|
212
|
+
threads.map(&:value)
|
213
|
+
end
|
214
|
+
ensure
|
215
|
+
threads.each(&:kill)
|
216
|
+
end
|
208
217
|
end
|
209
|
-
threads.map(&:value)
|
210
|
-
ensure
|
211
|
-
threads.each(&:kill)
|
212
218
|
end
|
213
219
|
|
214
220
|
def in_processes(options = {}, &block)
|
@@ -373,6 +379,7 @@ module Parallel
|
|
373
379
|
in_threads(options) do |i|
|
374
380
|
worker = workers[i]
|
375
381
|
worker.thread = Thread.current
|
382
|
+
worked = false
|
376
383
|
|
377
384
|
begin
|
378
385
|
loop do
|
@@ -381,8 +388,8 @@ module Parallel
|
|
381
388
|
break unless index
|
382
389
|
|
383
390
|
if options[:isolation]
|
384
|
-
worker = replace_worker(job_factory, workers, i, options, blk) if
|
385
|
-
|
391
|
+
worker = replace_worker(job_factory, workers, i, options, blk) if worked
|
392
|
+
worked = true
|
386
393
|
worker.thread = Thread.current
|
387
394
|
end
|
388
395
|
|
@@ -462,7 +469,10 @@ module Parallel
|
|
462
469
|
item, index = job_factory.unpack(data)
|
463
470
|
result = begin
|
464
471
|
call_with_index(item, index, options, &block)
|
465
|
-
|
472
|
+
# https://github.com/rspec/rspec-support/blob/673133cdd13b17077b3d88ece8d7380821f8d7dc/lib/rspec/support.rb#L132-L140
|
473
|
+
rescue NoMemoryError, SignalException, Interrupt, SystemExit
|
474
|
+
raise $!
|
475
|
+
rescue Exception
|
466
476
|
ExceptionWrapper.new($!)
|
467
477
|
end
|
468
478
|
begin
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parallel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: michael@grosser.it
|
@@ -23,7 +23,11 @@ files:
|
|
23
23
|
homepage: https://github.com/grosser/parallel
|
24
24
|
licenses:
|
25
25
|
- MIT
|
26
|
-
metadata:
|
26
|
+
metadata:
|
27
|
+
bug_tracker_uri: https://github.com/grosser/parallel/issues
|
28
|
+
documentation_uri: https://github.com/grosser/parallel/blob/v1.19.1/Readme.md
|
29
|
+
source_code_uri: https://github.com/grosser/parallel/tree/v1.19.1
|
30
|
+
wiki_uri: https://github.com/grosser/parallel/wiki
|
27
31
|
post_install_message:
|
28
32
|
rdoc_options: []
|
29
33
|
require_paths:
|
@@ -39,8 +43,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
43
|
- !ruby/object:Gem::Version
|
40
44
|
version: '0'
|
41
45
|
requirements: []
|
42
|
-
|
43
|
-
rubygems_version: 2.7.6
|
46
|
+
rubygems_version: 3.0.3
|
44
47
|
signing_key:
|
45
48
|
specification_version: 4
|
46
49
|
summary: Run any kind of code in parallel processes
|