async-container 0.16.8 → 0.16.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/container/controller.rb +9 -9
- data/lib/async/container/generic.rb +19 -7
- data/lib/async/container/group.rb +2 -2
- data/lib/async/container/notify/pipe.rb +1 -1
- data/lib/async/container/process.rb +2 -2
- data/lib/async/container/thread.rb +1 -3
- data/lib/async/container/version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18445205d04a2e5d27c5b54bb703f472fe518f3e4c15e31598991db3fcca5ba1
|
4
|
+
data.tar.gz: 49c69f7632a04ea49cdc6de33dc2c578a460d1572a8deed18d3c191f338857a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1c3aeca7295c56f6c893555521d4a1f6a7947027d70064856d96df591c7eaccb69a7ff2ae1884d9e53194cfe6fb8a5a0bfbfc110d1250832f1384dc47930789
|
7
|
+
data.tar.gz: b62caac02c27699441e005ced011e08efc4ad2577f440f00e13f17c025ad11a68f67efe976e04231e9f75517bb67643b1c5cc348ab31fba94f1d653d726af886
|
@@ -122,9 +122,9 @@ module Async
|
|
122
122
|
if @container
|
123
123
|
@notify&.restarting!
|
124
124
|
|
125
|
-
|
125
|
+
Console.logger.debug(self) {"Restarting container..."}
|
126
126
|
else
|
127
|
-
|
127
|
+
Console.logger.debug(self) {"Starting container..."}
|
128
128
|
end
|
129
129
|
|
130
130
|
container = self.create_container
|
@@ -138,9 +138,9 @@ module Async
|
|
138
138
|
end
|
139
139
|
|
140
140
|
# Wait for all child processes to enter the ready state.
|
141
|
-
|
141
|
+
Console.logger.debug(self, "Waiting for startup...")
|
142
142
|
container.wait_until_ready
|
143
|
-
|
143
|
+
Console.logger.debug(self, "Finished startup.")
|
144
144
|
|
145
145
|
if container.failed?
|
146
146
|
@notify&.error!($!.to_s)
|
@@ -154,7 +154,7 @@ module Async
|
|
154
154
|
old_container = @container
|
155
155
|
@container = container
|
156
156
|
|
157
|
-
|
157
|
+
Console.logger.debug(self, "Stopping old container...")
|
158
158
|
old_container&.stop
|
159
159
|
@notify&.ready!
|
160
160
|
rescue
|
@@ -168,7 +168,7 @@ module Async
|
|
168
168
|
def reload
|
169
169
|
@notify&.reloading!
|
170
170
|
|
171
|
-
|
171
|
+
Console.logger.info(self) {"Reloading container: #{@container}..."}
|
172
172
|
|
173
173
|
begin
|
174
174
|
self.setup(@container)
|
@@ -177,9 +177,9 @@ module Async
|
|
177
177
|
end
|
178
178
|
|
179
179
|
# Wait for all child processes to enter the ready state.
|
180
|
-
|
180
|
+
Console.logger.debug(self, "Waiting for startup...")
|
181
181
|
@container.wait_until_ready
|
182
|
-
|
182
|
+
Console.logger.debug(self, "Finished startup.")
|
183
183
|
|
184
184
|
if @container.failed?
|
185
185
|
@notify.error!("Container failed!")
|
@@ -215,7 +215,7 @@ module Async
|
|
215
215
|
begin
|
216
216
|
handler.call
|
217
217
|
rescue SetupError => error
|
218
|
-
|
218
|
+
Console.logger.error(self) {error}
|
219
219
|
end
|
220
220
|
else
|
221
221
|
raise
|
@@ -119,7 +119,7 @@ module Async
|
|
119
119
|
# @returns [Boolean] The children all became ready.
|
120
120
|
def wait_until_ready
|
121
121
|
while true
|
122
|
-
|
122
|
+
Console.logger.debug(self) do |buffer|
|
123
123
|
buffer.puts "Waiting for ready:"
|
124
124
|
@state.each do |child, state|
|
125
125
|
buffer.puts "\t#{child.class}: #{state.inspect}"
|
@@ -141,7 +141,7 @@ module Async
|
|
141
141
|
@group.stop(timeout)
|
142
142
|
|
143
143
|
if @group.running?
|
144
|
-
|
144
|
+
Console.logger.warn(self) {"Group is still running after stopping it!"}
|
145
145
|
end
|
146
146
|
ensure
|
147
147
|
@running = true
|
@@ -155,13 +155,13 @@ module Async
|
|
155
155
|
name ||= UNNAMED
|
156
156
|
|
157
157
|
if mark?(key)
|
158
|
-
|
158
|
+
Console.logger.debug(self) {"Reusing existing child for #{key}: #{name}"}
|
159
159
|
return false
|
160
160
|
end
|
161
161
|
|
162
162
|
@statistics.spawn!
|
163
163
|
|
164
|
-
|
164
|
+
fiber do
|
165
165
|
while @running
|
166
166
|
child = self.start(name, &block)
|
167
167
|
|
@@ -176,10 +176,10 @@ module Async
|
|
176
176
|
end
|
177
177
|
|
178
178
|
if status.success?
|
179
|
-
|
179
|
+
Console.logger.info(self) {"#{child} exited with #{status}"}
|
180
180
|
else
|
181
181
|
@statistics.failure!
|
182
|
-
|
182
|
+
Console.logger.error(self) {status}
|
183
183
|
end
|
184
184
|
|
185
185
|
if restart
|
@@ -189,7 +189,7 @@ module Async
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
# ensure
|
192
|
-
#
|
192
|
+
# Console.logger.error(self) {$!} if $!
|
193
193
|
end.resume
|
194
194
|
|
195
195
|
return true
|
@@ -270,6 +270,18 @@ module Async
|
|
270
270
|
|
271
271
|
@state.delete(child)
|
272
272
|
end
|
273
|
+
|
274
|
+
private
|
275
|
+
|
276
|
+
if Fiber.respond_to?(:blocking?)
|
277
|
+
def fiber(&block)
|
278
|
+
Fiber.new(blocking: true, &block)
|
279
|
+
end
|
280
|
+
else
|
281
|
+
def fiber(&block)
|
282
|
+
Fiber.new(&block)
|
283
|
+
end
|
284
|
+
end
|
273
285
|
end
|
274
286
|
end
|
275
287
|
end
|
@@ -78,7 +78,7 @@ module Async
|
|
78
78
|
# Interrupt all running processes.
|
79
79
|
# This resumes the controlling fiber with an instance of {Interrupt}.
|
80
80
|
def interrupt
|
81
|
-
|
81
|
+
Console.logger.debug(self, "Sending interrupt to #{@running.size} running processes...")
|
82
82
|
@running.each_value do |fiber|
|
83
83
|
fiber.resume(Interrupt)
|
84
84
|
end
|
@@ -87,7 +87,7 @@ module Async
|
|
87
87
|
# Terminate all running processes.
|
88
88
|
# This resumes the controlling fiber with an instance of {Terminate}.
|
89
89
|
def terminate
|
90
|
-
|
90
|
+
Console.logger.debug(self, "Sending terminate to #{@running.size} running processes...")
|
91
91
|
@running.each_value do |fiber|
|
92
92
|
fiber.resume(Terminate)
|
93
93
|
end
|
@@ -91,7 +91,7 @@ module Async
|
|
91
91
|
rescue Interrupt
|
92
92
|
# Graceful exit.
|
93
93
|
rescue Exception => error
|
94
|
-
|
94
|
+
Console.logger.error(self) {error}
|
95
95
|
|
96
96
|
exit!(1)
|
97
97
|
end
|
@@ -177,7 +177,7 @@ module Async
|
|
177
177
|
end
|
178
178
|
|
179
179
|
if @status.nil?
|
180
|
-
|
180
|
+
Console.logger.warn(self) {"Process #{@pid} is blocking, has it exited?"}
|
181
181
|
_, @status = ::Process.wait2(@pid)
|
182
182
|
end
|
183
183
|
end
|
@@ -24,8 +24,6 @@ require_relative 'channel'
|
|
24
24
|
require_relative 'error'
|
25
25
|
require_relative 'notify/pipe'
|
26
26
|
|
27
|
-
require 'async/logger'
|
28
|
-
|
29
27
|
module Async
|
30
28
|
module Container
|
31
29
|
# Represents a running child thread from the point of view of the parent container.
|
@@ -207,7 +205,7 @@ module Async
|
|
207
205
|
# Invoked by the @waiter thread to indicate the outcome of the child thread.
|
208
206
|
def finished(error = nil)
|
209
207
|
if error
|
210
|
-
|
208
|
+
Console.logger.error(self) {error}
|
211
209
|
end
|
212
210
|
|
213
211
|
@status = Status.new(error)
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-container
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: async-io
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: async-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.2.22
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Abstract container-based parallelism using threads and processes where appropriate.
|