parallel 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -1
- data.tar.gz.sig +0 -0
- data/lib/parallel.rb +19 -4
- data/lib/parallel/version.rb +1 -1
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41798e8a531680e30ebcc41d1fa32527a03b062e
|
4
|
+
data.tar.gz: 9573be00fe55ad7bfac10b11af093bf729085b24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c11b276f31a4f08ff4d91a33626c0daab3a903d1b1f5e7b0450f3837ab5076cefa9fcd458decff08444d62c4a9f28eb2c9447b7f4f7e7fcafbe96c9e8d53e918
|
7
|
+
data.tar.gz: 24b9dfdd2058018a3eba26d9cb2177f1fcab0b95517630704facec2ab1c3254251503cb2881e9574f2b13f8cd023ddcd18fa5b71480aa36161fed260bbcf2cf3
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
�c��n<RAI��_�A���X~8�D��{ǰ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
|
data/lib/parallel.rb
CHANGED
@@ -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
|
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
|
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
|
-
|
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
|
data/lib/parallel/version.rb
CHANGED
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|