parallel 1.16.1 → 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9d71c7c1cb0ec5616b0e53cc1e7e04f4243046a05e43ccd3450aea7623e66a7
4
- data.tar.gz: 0ba58d01bcc3b2150f82deccc4937e2977e1428dddf89d88ecdb99163be58540
3
+ metadata.gz: da9740ffe51b7c2867eb4a51b9477aa0195c475ba27342793a3a6f7aa209b9ab
4
+ data.tar.gz: cc98ae0e7c35557d064abf720263258a0340c30ec405d30342636f1667fc32c1
5
5
  SHA512:
6
- metadata.gz: 28b1580182981900e12c8e1e839395e6e37fce2f0d5e953931a80a92e6f4d1496abe4c626f7344194674a7432f9c0956556353a3764d5d6ff4bb9f1ca20fd813
7
- data.tar.gz: 71740d5aea1407881bc1415cad4b959e21538df22308f609f6d5becbf3dd32cc8427057ff845b1a91614ec2da867fae8604b6495b353b7e40dc07de678500dfe
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 and used for process scheduling. It's just wrapper for Etc.nprocessors
6
+ # Number of processors seen by the OS, used for process scheduling
6
7
  def processor_count
7
- @processor_count ||= begin
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"]
@@ -1,3 +1,3 @@
1
1
  module Parallel
2
- VERSION = Version = '1.16.1'
2
+ VERSION = Version = '1.19.1'
3
3
  end
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, :lap
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
- count, _ = extract_count_from_options(options)
206
- threads = Array.new(count) do |i|
207
- Thread.new { yield(i) }
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 worker.lap > 0
385
- worker.lap += 1
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
- rescue
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.16.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-03-28 00:00:00.000000000 Z
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
- rubyforge_project:
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