async-container 0.27.0 → 0.27.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7beb84adfd9648242dc7850eab94f4d080fea57d2ff218a02950c18008b0d2c5
4
- data.tar.gz: c558b447f4f4273350e5be255a6916020592a747243a6f5a3a937bea114b905c
3
+ metadata.gz: 7d43fc927cb1564c1ed256976873b66245386fe54d11467935184c1f38da9d96
4
+ data.tar.gz: 3738e9b3009bd87388fe23c34085d99a4ba384fe8ef274465ec732a8398f6b7b
5
5
  SHA512:
6
- metadata.gz: 8b6bdc0e7268ef3c39f0591c9d3d4d5609b6a0e0cec112a69d6d0563e891af0caee0af78f98afa5dcf74f4cb0b8167e69f6afeb4c7ef7437a0f8717c0d1423d3
7
- data.tar.gz: df8b60f1e3d9b4efb9b677605cc1dad130f8be806b282c4ef6522e809d62edc985432b49d1d2458e47d142e0a489a4c4d6db00cd0194cca5af386a2addcbd5c5
6
+ metadata.gz: 14700cf9cb8952affd49569383348715fa357660b809f033a1a0d345a03f3b16145ec868b07022df1bece5224008a49ce78441d86113ef18c94530247fadf104
7
+ data.tar.gz: 7665c5a66280b04bd835e9708e81fff08ab5116ab07886fae1aa3c3b155bef6011167d10bcdb63b08c3a877d5df795dd3901740a0e46ac0a433ff7cf024feac1
checksums.yaml.gz.sig CHANGED
Binary file
@@ -91,11 +91,11 @@ module Async
91
91
  # Start the container unless it's already running.
92
92
  def start
93
93
  unless @container
94
- Console.info(self) {"Controller starting..."}
94
+ Console.info(self, "Controller starting...")
95
95
  self.restart
96
96
  end
97
97
 
98
- Console.info(self) {"Controller started..."}
98
+ Console.info(self, "Controller started...")
99
99
  end
100
100
 
101
101
  # Stop the container if it's running.
@@ -111,9 +111,9 @@ module Async
111
111
  if @container
112
112
  @notify&.restarting!
113
113
 
114
- Console.debug(self) {"Restarting container..."}
114
+ Console.info(self, "Restarting container...")
115
115
  else
116
- Console.debug(self) {"Starting container..."}
116
+ Console.info(self, "Starting container...")
117
117
  end
118
118
 
119
119
  container = self.create_container
@@ -127,13 +127,14 @@ module Async
127
127
  end
128
128
 
129
129
  # Wait for all child processes to enter the ready state.
130
- Console.debug(self, "Waiting for startup...")
130
+ Console.info(self, "Waiting for startup...")
131
131
  container.wait_until_ready
132
- Console.debug(self, "Finished startup.")
132
+ Console.info(self, "Finished startup.")
133
133
 
134
134
  if container.failed?
135
135
  @notify&.error!("Container failed to start!")
136
136
 
137
+ Console.info(self, "Stopping failed container...")
137
138
  container.stop(false)
138
139
 
139
140
  raise SetupError, container
@@ -145,7 +146,7 @@ module Async
145
146
  container = nil
146
147
 
147
148
  if old_container
148
- Console.debug(self, "Stopping old container...")
149
+ Console.info(self, "Stopping old container...")
149
150
  old_container&.stop(@graceful_stop)
150
151
  end
151
152
 
@@ -168,11 +169,9 @@ module Async
168
169
  end
169
170
 
170
171
  # Wait for all child processes to enter the ready state.
171
- Console.debug(self, "Waiting for startup...")
172
-
172
+ Console.info(self, "Waiting for startup...")
173
173
  @container.wait_until_ready
174
-
175
- Console.debug(self, "Finished startup.")
174
+ Console.info(self, "Finished startup.")
176
175
 
177
176
  if @container.failed?
178
177
  @notify.error!("Container failed to reload!")
@@ -235,7 +235,7 @@ module Async
235
235
  # @returns [::Process::Status] The process exit status.
236
236
  def wait(timeout = 0.1)
237
237
  if @pid && @status.nil?
238
- Console.debug(self, "Waiting for process to exit...", pid: @pid)
238
+ Console.debug(self, "Waiting for process to exit...", child: {process_id: @pid}, timeout: timeout)
239
239
 
240
240
  _, @status = ::Process.wait2(@pid, ::Process::WNOHANG)
241
241
 
@@ -245,7 +245,7 @@ module Async
245
245
  _, @status = ::Process.wait2(@pid, ::Process::WNOHANG)
246
246
 
247
247
  if @status.nil?
248
- Console.warn(self) {"Process #{@pid} is blocking, sending kill signal..."}
248
+ Console.warn(self, "Process is blocking, sending kill signal...", child: {process_id: @pid}, caller: caller_locations, timeout: timeout)
249
249
  self.kill!
250
250
 
251
251
  # Wait for the process to exit:
@@ -254,7 +254,7 @@ module Async
254
254
  end
255
255
  end
256
256
 
257
- Console.debug(self, "Process exited.", pid: @pid, status: @status)
257
+ Console.debug(self, "Process exited.", child: {process_id: @pid, status: @status})
258
258
 
259
259
  return @status
260
260
  end
@@ -139,12 +139,18 @@ module Async
139
139
  # Stop the children instances.
140
140
  # @parameter timeout [Boolean | Numeric] Whether to stop gracefully, or a specific timeout.
141
141
  def stop(timeout = true)
142
+ Console.info(self, "Stopping container...", timeout: timeout, caller: caller_locations)
142
143
  @running = false
143
144
  @group.stop(timeout)
144
145
 
145
146
  if @group.running?
146
- Console.warn(self) {"Group is still running after stopping it!"}
147
+ Console.warn(self, "Group is still running after stopping it!")
148
+ else
149
+ Console.info(self, "Group has stopped.")
147
150
  end
151
+ rescue => error
152
+ Console.error(self, "Error while stopping container!", exception: error)
153
+ raise
148
154
  ensure
149
155
  @running = true
150
156
  end
@@ -165,7 +171,7 @@ module Async
165
171
  name ||= UNNAMED
166
172
 
167
173
  if mark?(key)
168
- Console.debug(self) {"Reusing existing child for #{key}: #{name}"}
174
+ Console.debug(self, "Reusing existing child.", child: {key: key, name: name})
169
175
  return false
170
176
  end
171
177
 
@@ -199,10 +205,10 @@ module Async
199
205
  end
200
206
 
201
207
  if status.success?
202
- Console.debug(self) {"#{child} exited with #{status}"}
208
+ Console.info(self, "Child exited successfully.", status: status, running: @running)
203
209
  else
204
210
  @statistics.failure!
205
- Console.error(self, status: status)
211
+ Console.error(self, "Child exited with error!", status: status, running: @running)
206
212
  end
207
213
 
208
214
  if restart
@@ -211,6 +217,11 @@ module Async
211
217
  break
212
218
  end
213
219
  end
220
+ rescue => error
221
+ Console.error(self, "Failure during child process management!", exception: error, running: @running)
222
+ raise
223
+ ensure
224
+ Console.info(self, "Child process management loop exited.", running: @running)
214
225
  end.resume
215
226
 
216
227
  return true
@@ -12,7 +12,7 @@ module Async
12
12
  module Container
13
13
  # The default timeout for interrupting processes, before escalating to terminating.
14
14
  INTERRUPT_TIMEOUT = ENV.fetch("ASYNC_CONTAINER_INTERRUPT_TIMEOUT", 10).to_f
15
-
15
+
16
16
  # The default timeout for terminating processes, before escalating to killing.
17
17
  TERMINATE_TIMEOUT = ENV.fetch("ASYNC_CONTAINER_TERMINATE_TIMEOUT", 10).to_f
18
18
 
@@ -222,10 +222,10 @@ module Async
222
222
  # @returns [Status]
223
223
  def wait(timeout = 0.1)
224
224
  if @waiter
225
- Console.debug(self, "Waiting for thread to exit...", timeout: timeout)
225
+ Console.debug(self, "Waiting for thread to exit...", child: {thread_id: @thread.object_id}, timeout: timeout)
226
226
 
227
227
  unless @waiter.join(timeout)
228
- Console.warn(self) {"Thread #{@thread} is blocking, sending kill signal..."}
228
+ Console.warn(self, "Thread is blocking, sending kill signal...", child: {thread_id: @thread.object_id}, caller: caller_locations, timeout: timeout)
229
229
  self.kill!
230
230
  @waiter.join
231
231
  end
@@ -233,6 +233,8 @@ module Async
233
233
  @waiter = nil
234
234
  end
235
235
 
236
+ Console.debug(self, "Thread exited.", child: {thread_id: @thread.object_id, status: @status})
237
+
236
238
  return @status
237
239
  end
238
240
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Container
8
- VERSION = "0.27.0"
8
+ VERSION = "0.27.2"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -26,6 +26,14 @@ Please see the [project documentation](https://socketry.github.io/async-containe
26
26
 
27
27
  Please see the [project releases](https://socketry.github.io/async-container/releases/index) for all releases.
28
28
 
29
+ ### v0.27.2
30
+
31
+ - More logging, especially around failure cases.
32
+
33
+ ### v0.27.1
34
+
35
+ - Log caller and timeout when waiting on a child instance to exit, if it blocks.
36
+
29
37
  ### v0.27.0
30
38
 
31
39
  - Increased default interrupt timeout and terminate timeout to 10 seconds each.
data/releases.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Releases
2
2
 
3
+ ## v0.27.2
4
+
5
+ - More logging, especially around failure cases.
6
+
7
+ ## v0.27.1
8
+
9
+ - Log caller and timeout when waiting on a child instance to exit, if it blocks.
10
+
3
11
  ## v0.27.0
4
12
 
5
13
  - Increased default interrupt timeout and terminate timeout to 10 seconds each.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.27.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
- rubygems_version: 3.6.9
108
+ rubygems_version: 3.7.2
109
109
  specification_version: 4
110
110
  summary: Abstract container-based parallelism using threads and processes where appropriate.
111
111
  test_files: []
metadata.gz.sig CHANGED
Binary file