parallel 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ddf2d8203167b88c7236cff2d35bad7532f375d6
4
- data.tar.gz: b07e88749f615799fa2791fd3f860db76bb51dde
3
+ metadata.gz: e4e78d815458047cedffa16bc96039d7e3190c91
4
+ data.tar.gz: 61b2f747f5316c87243377f29360cf5d672cb162
5
5
  SHA512:
6
- metadata.gz: 5401bcaeac66a97ffb01082f22e7c700adf3d6ad869a2a674bdd5ff5e2444cc9d0d9132be2b66dd813d87ec47e05795fb21efe21c1f5b142ad19ade34c9888c3
7
- data.tar.gz: 0240f79864e6c479711632c8275c0a7e391198eec937cb76de38d9d45ce47ce059d4d7a9fcfb262d36bc79ae1cb4e4bcf43520eb624231c12f6fda6c37cdf4ba
6
+ metadata.gz: 04f1cbad473a3120c8b1d4092e9a6e264c77d480ebc50c2b1ddaac61310b998cef3de43c14bdd9d276485303f890a7d3ac7f2aaf3fd15181e4e01402aa10effc
7
+ data.tar.gz: 30e97bd0a5bbac98e151cb06eb8d16989d51fa4d9446b7c9415b9cc4c70bf363cf84850165e51428eeeb754499fafe3e69b503ed769300f5be4c2d92bf16c58e
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/parallel.rb CHANGED
@@ -136,7 +136,7 @@ module Parallel
136
136
  end
137
137
  end
138
138
 
139
- kill_on_ctrl_c(threads) { wait_for_threads(threads) }
139
+ kill_on_ctrl_c(threads, options) { wait_for_threads(threads) }
140
140
 
141
141
  out
142
142
  end
@@ -227,7 +227,7 @@ module Parallel
227
227
  results = []
228
228
  exception = nil
229
229
 
230
- in_threads(options[:count]) do
230
+ in_threads(options) do
231
231
  # as long as there are more items, work on one of them
232
232
  loop do
233
233
  break if exception
@@ -253,8 +253,8 @@ module Parallel
253
253
  results = []
254
254
  exception = nil
255
255
 
256
- kill_on_ctrl_c(workers.map(&:pid)) do
257
- in_threads(options[:count]) do |i|
256
+ kill_on_ctrl_c(workers.map(&:pid), options) do
257
+ in_threads(options) do |i|
258
258
  worker = workers[i]
259
259
  worker.thread = Thread.current
260
260
 
@@ -368,12 +368,13 @@ module Parallel
368
368
  end
369
369
 
370
370
  # kill all these pids or threads if user presses Ctrl+c
371
- def kill_on_ctrl_c(things)
371
+ def kill_on_ctrl_c(things, options)
372
372
  @to_be_killed ||= []
373
373
  old_interrupt = nil
374
+ signal = options.fetch(:interrupt_signal, INTERRUPT_SIGNAL)
374
375
 
375
376
  if @to_be_killed.empty?
376
- old_interrupt = trap_interrupt do
377
+ old_interrupt = trap_interrupt(signal) do
377
378
  $stderr.puts 'Parallel execution interrupted, exiting ...'
378
379
  @to_be_killed.flatten.compact.each { |thing| kill_that_thing!(thing) }
379
380
  end
@@ -384,13 +385,13 @@ module Parallel
384
385
  yield
385
386
  ensure
386
387
  @to_be_killed.pop # free threads for GC and do not kill pids that could be used for new processes
387
- restore_interrupt(old_interrupt) if @to_be_killed.empty?
388
+ restore_interrupt(old_interrupt, signal) if @to_be_killed.empty?
388
389
  end
389
390
 
390
- def trap_interrupt
391
- old = Signal.trap INTERRUPT_SIGNAL, 'IGNORE'
391
+ def trap_interrupt(signal)
392
+ old = Signal.trap signal, 'IGNORE'
392
393
 
393
- Signal.trap INTERRUPT_SIGNAL do
394
+ Signal.trap signal do
394
395
  yield
395
396
  if old == "DEFAULT"
396
397
  raise Interrupt
@@ -402,8 +403,8 @@ module Parallel
402
403
  old
403
404
  end
404
405
 
405
- def restore_interrupt(old)
406
- Signal.trap INTERRUPT_SIGNAL, old
406
+ def restore_interrupt(old, signal)
407
+ Signal.trap signal, old
407
408
  end
408
409
 
409
410
  def kill_that_thing!(thing)
@@ -1,3 +1,3 @@
1
1
  module Parallel
2
- VERSION = Version = '1.3.1'
2
+ VERSION = Version = '1.3.2'
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.3.1
4
+ version: 1.3.2
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-09-04 00:00:00.000000000 Z
33
+ date: 2014-09-12 00:00:00.000000000 Z
34
34
  dependencies: []
35
35
  description:
36
36
  email: michael@grosser.it
metadata.gz.sig CHANGED
Binary file