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 +4 -4
- data/chantier.gemspec +2 -2
- data/lib/chantier.rb +1 -1
- data/lib/process_pool_with_kill.rb +3 -3
- data/spec/process_pool_with_kill_spec.rb +15 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ad91f24a7bd64070ce2d9943a1340a786348fa5
|
4
|
+
data.tar.gz: ae221e941dd3d8994644e4179d7684e60c9cf234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0752ee267d03dbb4b9abfa5541d11faf302b0c549355b1ea1b0dc6a6d5dfaabf7f3f42beaf72705faada50c7bab2d8b30b9fbeaa1f59b8c6e50640d99833745a
|
7
|
+
data.tar.gz: 2249fe8959c9b8086e2c68960738e78bfd79b6cb78b3d7f3889df1a721fe75a996731cce407f1f29d7a326bf1adbb0931c02c926a07ca67c0489ec96a7a178a2
|
data/chantier.gemspec
CHANGED
@@ -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
|
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 = "
|
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"]
|
data/lib/chantier.rb
CHANGED
@@ -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,
|
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
|
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,
|
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
|
|