chantier 1.0.5 → 2.0.0

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: 9f7e3721971fc3b264faba767be38065cd763f97
4
- data.tar.gz: 615d99c6ffccc92804ca9ce6eae1e9e4b7dda18d
3
+ metadata.gz: 1ad91f24a7bd64070ce2d9943a1340a786348fa5
4
+ data.tar.gz: ae221e941dd3d8994644e4179d7684e60c9cf234
5
5
  SHA512:
6
- metadata.gz: 962aa2648f78ce54fdf25af4c272b4a5babb99c2f7ad7fe2edbeadd772180bde851eecea335d75e5e6983b6111ea42854afd56a7a7580ecbdebca94501dfc4d4
7
- data.tar.gz: f47eb5fcdd418b5fc78e3a77716eeb42c2cf781100fc22b9528c72b44699d90a564dfdd50c0593e030140189cb68dcb779398701ab79afb9bed5b98b8701a2d3
6
+ metadata.gz: 0752ee267d03dbb4b9abfa5541d11faf302b0c549355b1ea1b0dc6a6d5dfaabf7f3f42beaf72705faada50c7bab2d8b30b9fbeaa1f59b8c6e50640d99833745a
7
+ data.tar.gz: 2249fe8959c9b8086e2c68960738e78bfd79b6cb78b3d7f3889df1a721fe75a996731cce407f1f29d7a326bf1adbb0931c02c926a07ca67c0489ec96a7a178a2
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: chantier 1.0.5 ruby lib
5
+ # stub: chantier 2.0.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "chantier"
9
- s.version = "1.0.5"
9
+ s.version = "2.0.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -1,5 +1,5 @@
1
1
  module Chantier
2
- VERSION = '1.0.5'
2
+ VERSION = '2.0.0'
3
3
  require_relative 'process_pool'
4
4
  require_relative 'process_pool_with_kill'
5
5
  require_relative 'thread_pool'
@@ -2,7 +2,7 @@
2
2
  # maintains a pool of those proceses (same as ProcessPool). Will also forcibly quit
3
3
  # those processes after a certain period to ensure they do not hang
4
4
  #
5
- # manager = ProcessPoolWithKill.new(slots = 4, kill_after = 5) # seconds
5
+ # manager = ProcessPoolWithKill.new(slots = 4, kill_after_seconds: 5) # seconds
6
6
  # jobs_hose.each_job do | job |
7
7
  # # this call will block until a slot becomes available
8
8
  # manager.fork_task do # this block runs in a subprocess
@@ -18,9 +18,9 @@ class Chantier::ProcessPoolWithKill < Chantier::ProcessPool
18
18
  TERMINATION_SIGNALS = %w( TERM HUP INT QUIT PIPE KILL )
19
19
 
20
20
  DEFAULT_KILL_TIMEOUT = 60
21
- def initialize(num_procs, kill_after_seconds = DEFAULT_KILL_TIMEOUT)
21
+ def initialize(num_procs, kill_after_seconds: DEFAULT_KILL_TIMEOUT, **kwargs)
22
22
  @kill_after_seconds = kill_after_seconds.to_f
23
- super(num_procs)
23
+ super(num_procs, **kwargs)
24
24
  end
25
25
 
26
26
  # Run the given block in a forked subprocess. This method will block
@@ -83,7 +83,7 @@ describe Chantier::ProcessPoolWithKill do
83
83
  end
84
84
 
85
85
  it 'forcibly quites a process that is hung for too long' do
86
- manager_with_short_timeout = described_class.new(1, timeout=0.4)
86
+ manager_with_short_timeout = described_class.new(1, kill_after_seconds: 0.4)
87
87
 
88
88
  filename = SecureRandom.hex(22)
89
89
  manager_with_short_timeout.fork_task do
@@ -98,6 +98,20 @@ describe Chantier::ProcessPoolWithKill do
98
98
  end
99
99
  end
100
100
 
101
+ context 'with failures' do
102
+ class AlwaysWrong
103
+ def arm!; end
104
+ def limit_reached?; true; end
105
+ end
106
+
107
+ it 'honors the failure policy object passed in' do
108
+ subject = described_class.new(5, failure_policy: AlwaysWrong.new)
109
+ expect {
110
+ subject.fork_task { "never happens" }
111
+ }.to raise_error("Reached error limit of processes quitting with non-0 status")
112
+ end
113
+ end
114
+
101
115
  context 'with 5 slots' do
102
116
  let(:manager) { described_class.new(5) }
103
117
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chantier
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov