parallel 1.1.2 → 1.2.0
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 +0 -0
- data.tar.gz.sig +0 -0
- data/lib/parallel.rb +32 -10
- data/lib/parallel/version.rb +1 -1
- metadata +2 -2
- 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: 11290960cd496e43b8e7c9314769ffc8a3554daa
|
4
|
+
data.tar.gz: bfc4d8c942312266e0fbe3ebc66f0fd19923fffe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90cd2a5f9af376e208f64483b416ea23cb92de3ac03eb8c5fbb2cf86576717d846dfaa8a3d0dd8a183a4543c855b81978829b09325e7b0e7f32283b8ff69dcfa
|
7
|
+
data.tar.gz: 066e43a835be012a025536bbfcf0f2ff7ed8bd50a9295d760b44b3f10492be3496e36154ff816717126dd0dd3b53cd1152340b01db025b60e46a30609a65e9d3
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/parallel.rb
CHANGED
@@ -12,6 +12,8 @@ module Parallel
|
|
12
12
|
class Kill < StandardError
|
13
13
|
end
|
14
14
|
|
15
|
+
INTERRUPT_SIGNAL = :SIGINT
|
16
|
+
|
15
17
|
class ExceptionWrapper
|
16
18
|
attr_reader :exception
|
17
19
|
def initialize(exception)
|
@@ -360,21 +362,41 @@ module Parallel
|
|
360
362
|
|
361
363
|
# kill all these pids or threads if user presses Ctrl+c
|
362
364
|
def kill_on_ctrl_c(things)
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
@to_be_killed.flatten.compact.each { |thing| kill_that_thing!(thing) }
|
371
|
-
end
|
372
|
-
exit 1 # Quit with 'failed' signal
|
365
|
+
@to_be_killed ||= []
|
366
|
+
old_interrupt = nil
|
367
|
+
|
368
|
+
if @to_be_killed.empty?
|
369
|
+
old_interrupt = trap_interrupt do
|
370
|
+
$stderr.puts 'Parallel execution interrupted, exiting ...'
|
371
|
+
@to_be_killed.flatten.compact.each { |thing| kill_that_thing!(thing) }
|
373
372
|
end
|
374
373
|
end
|
374
|
+
|
375
|
+
@to_be_killed << things
|
376
|
+
|
375
377
|
yield
|
376
378
|
ensure
|
377
379
|
@to_be_killed.pop # free threads for GC and do not kill pids that could be used for new processes
|
380
|
+
restore_interrupt(old_interrupt) if @to_be_killed.empty?
|
381
|
+
end
|
382
|
+
|
383
|
+
def trap_interrupt
|
384
|
+
old = Signal.trap INTERRUPT_SIGNAL, 'IGNORE'
|
385
|
+
|
386
|
+
Signal.trap INTERRUPT_SIGNAL do
|
387
|
+
yield
|
388
|
+
if old == "DEFAULT"
|
389
|
+
raise Interrupt
|
390
|
+
else
|
391
|
+
old.call
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
old
|
396
|
+
end
|
397
|
+
|
398
|
+
def restore_interrupt(old)
|
399
|
+
Signal.trap INTERRUPT_SIGNAL, old
|
378
400
|
end
|
379
401
|
|
380
402
|
def kill_that_thing!(thing)
|
data/lib/parallel/version.rb
CHANGED
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.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
F5etKHZg0j3eHO31/i2HnswY04lqGImUu6aM5EnijFTB7PPW2KwKKM4+kKDYFdlw
|
31
31
|
/0WV1Ng2/Y6qsHwmqGg2VlYj2h4=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2014-07
|
33
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
34
34
|
dependencies: []
|
35
35
|
description:
|
36
36
|
email: michael@grosser.it
|
metadata.gz.sig
CHANGED
Binary file
|