parallel 1.1.0 → 1.1.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
  SHA1:
3
- metadata.gz: 2d6eba22bc6a58bd81015a14fc172be0e153d91d
4
- data.tar.gz: 7141912375eb2e22d01c1cec0adc9de9959cdd3f
3
+ metadata.gz: 41798e8a531680e30ebcc41d1fa32527a03b062e
4
+ data.tar.gz: 9573be00fe55ad7bfac10b11af093bf729085b24
5
5
  SHA512:
6
- metadata.gz: 0928cea0bdb78c8f2eca63f3a4fc91c77762d775d1290ba98ee9b4e827d1dc34a411909ed8eb7769fc30039859731a1b50e7bb7b0e559451a17ca78fd3a4dacf
7
- data.tar.gz: 0703748023b1f658f47aba8ee163b1d2ca7a349343f76efdcd5397474fcb44b21a76a026fcf14d22cf09b64db80c047f3111ac22802779a5da9386dca839b374
6
+ metadata.gz: c11b276f31a4f08ff4d91a33626c0daab3a903d1b1f5e7b0450f3837ab5076cefa9fcd458decff08444d62c4a9f28eb2c9447b7f4f7e7fcafbe96c9e8d53e918
7
+ data.tar.gz: 24b9dfdd2058018a3eba26d9cb2177f1fcab0b95517630704facec2ab1c3254251503cb2881e9574f2b13f8cd023ddcd18fa5b71480aa36161fed260bbcf2cf3
@@ -1 +1,2 @@
1
- 1O9ڥ9�џ؍�N@nVr�c2]>ȗ@��ɻ�^���n$��ߓi{���#�QJ`u��4�����6aB�[����cb3��l =3h� 5���*���7[�ێ�d�<fWX8�>5^s�ݯ�����Ҭ���n9�xB?�;}@������׉� �b.����~��ҧ�M�|Ѡ�p3f N�j��p2y!��>� �ӰT7�����cK�X}��&���9�=���m�F�d �5&r�\��.
1
+ c��n<RAI��_�A���X~8D��{ǰP{����s�
2
+ ��l�U����ȳ���������7Iae&ċIV�ͅ�O��G ����$���(�P��OUW����R���K=�i�\��v�$<�xa��bXԓ䙰�HT�z�< ��w�JLG�w�G��Ym�}���D�BG�M��^�%�W-jϷ���=� �J� r~�U�4y�K�:@��&ɨT�d������o$�D<3>%���c����s�=��㕆�ޠ
data.tar.gz.sig CHANGED
Binary file
@@ -9,6 +9,9 @@ module Parallel
9
9
  class Break < StandardError
10
10
  end
11
11
 
12
+ class Kill < StandardError
13
+ end
14
+
12
15
  class ExceptionWrapper
13
16
  attr_reader :exception
14
17
  def initialize(exception)
@@ -23,6 +26,7 @@ module Parallel
23
26
 
24
27
  class Worker
25
28
  attr_reader :pid, :read, :write
29
+ attr_accessor :silent_death
26
30
  def initialize(read, write, pid)
27
31
  @read, @write, @pid = read, write, pid
28
32
  end
@@ -48,7 +52,7 @@ module Parallel
48
52
  begin
49
53
  Marshal.load(read)
50
54
  rescue EOFError
51
- raise DeadWorker
55
+ raise DeadWorker unless silent_death
52
56
  end
53
57
  end
54
58
  end
@@ -227,7 +231,7 @@ module Parallel
227
231
  with_instrumentation items[index], index, options do
228
232
  begin
229
233
  results[index] = call_with_index(items, index, options, &block)
230
- rescue Exception => e
234
+ rescue StandardError => e
231
235
  exception = e
232
236
  break
233
237
  end
@@ -259,6 +263,10 @@ module Parallel
259
263
 
260
264
  if ExceptionWrapper === output
261
265
  exception = output.exception
266
+ if Parallel::Kill === exception
267
+ workers.each { |w| w.silent_death = true }
268
+ kill_everything_we_spawned
269
+ end
262
270
  else
263
271
  results[index] = output
264
272
  end
@@ -331,7 +339,7 @@ module Parallel
331
339
  end
332
340
 
333
341
  def handle_exception(exception, results)
334
- return nil if exception.class == Parallel::Break
342
+ return nil if [Parallel::Break, Parallel::Kill].include? exception.class
335
343
  raise exception if exception
336
344
  results
337
345
  end
@@ -356,7 +364,7 @@ module Parallel
356
364
  Signal.trap :SIGINT do
357
365
  if @to_be_killed.any?
358
366
  $stderr.puts 'Parallel execution interrupted, exiting ...'
359
- @to_be_killed.flatten.compact.each { |thing| kill_that_thing!(thing) }
367
+ kill_everything_we_spawned
360
368
  end
361
369
  exit 1 # Quit with 'failed' signal
362
370
  end
@@ -366,6 +374,13 @@ module Parallel
366
374
  @to_be_killed.pop # free threads for GC and do not kill pids that could be used for new processes
367
375
  end
368
376
 
377
+ def kill_everything_we_spawned
378
+ if defined?(@to_be_killed)
379
+ @to_be_killed.flatten.compact.each { |thing| kill_that_thing!(thing) }
380
+ @to_be_killed = [] # in case the ctrl+c kicks in later ...
381
+ end
382
+ end
383
+
369
384
  def kill_that_thing!(thing)
370
385
  if thing.is_a?(Thread)
371
386
  thing.kill
@@ -1,3 +1,3 @@
1
1
  module Parallel
2
- VERSION = Version = '1.1.0'
2
+ VERSION = Version = '1.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
metadata.gz.sig CHANGED
Binary file