async-container 0.27.4 → 0.27.6

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: a81d686d7bcf4debd164fb322e88e4da3bbc9224d5191c49f020d386b996ecf4
4
- data.tar.gz: fd4ff31ee2a1b3b03d4a72b9b73ae1e398bff6966b8b68759c27f0db6972b825
3
+ metadata.gz: e24f5190b56ac438bc6944606f03b532842f4941ddce2aafdd4da22e84ebb2d2
4
+ data.tar.gz: 7808c2b84c7588a98ff110a3d9409a3daba3dc91d5effe97e6b5e8d6be14a85c
5
5
  SHA512:
6
- metadata.gz: b3ab253a07c2c1878c316d3bd19a6889969741ccaea279dc4e1d9787f1ffd4973445f98f9262b8dfa0d1d30dda0114327226e14696632ec8813ab7648a37e95f
7
- data.tar.gz: bf928811afebfd226c25ca62d368624f6914a283d07470277ee159903694e412268c6e2d2965cbe834ea9205c097ca2d8a78eb8f3664cb6a74fca4fe8c90c9c4
6
+ metadata.gz: bbcefc876ceea7648bda5543ff6fbfa5756fa19808e7cc725c3a7e3e97be63c3f591227861c8f0aa067ff2559a4f097c951a042b2d30e279300b22a9ced1e2fd
7
+ data.tar.gz: 04de5a914ebcd62fc58c11daa52bcf35342bd336bee0ac83a2b1f7d2c51c0c2631c08330de70c3ece2d250c37beb6e5f516a6e8b5088f903f160352711bcbc55
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2024, by Samuel Williams.
4
+ # Copyright, 2020-2025, by Samuel Williams.
5
5
 
6
6
  require "json"
7
7
 
@@ -10,8 +10,9 @@ module Async
10
10
  # Provides a basic multi-thread/multi-process uni-directional communication channel.
11
11
  class Channel
12
12
  # Initialize the channel using a pipe.
13
- def initialize
13
+ def initialize(timeout: 1.0)
14
14
  @in, @out = ::IO.pipe
15
+ @in.timeout = timeout
15
16
  end
16
17
 
17
18
  # The input end of the pipe.
@@ -43,12 +44,11 @@ module Async
43
44
  # @returns [Hash]
44
45
  def receive
45
46
  if data = @in.gets
46
- begin
47
- return JSON.parse(data, symbolize_names: true)
48
- rescue
49
- return {line: data}
50
- end
47
+ return JSON.parse(data, symbolize_names: true)
51
48
  end
49
+ rescue => error
50
+ Console.error(self, "Error during channel receive!", error)
51
+ return nil
52
52
  end
53
53
  end
54
54
  end
@@ -136,8 +136,8 @@ module Async
136
136
 
137
137
  # Initialize the process.
138
138
  # @parameter name [String] The name to use for the child process.
139
- def initialize(name: nil)
140
- super()
139
+ def initialize(name: nil, **options)
140
+ super(**options)
141
141
 
142
142
  @name = name
143
143
  @status = nil
@@ -2,6 +2,7 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2019-2025, by Samuel Williams.
5
+ # Copyright, 2025, by Marc-André Cournoyer.
5
6
 
6
7
  require "etc"
7
8
  require "async/clock"
@@ -191,6 +192,8 @@ module Async
191
192
  age_clock = state[:age] = Clock.start
192
193
  end
193
194
 
195
+ status = nil
196
+
194
197
  begin
195
198
  status = @group.wait_for(child) do |message|
196
199
  case message
@@ -203,11 +206,13 @@ module Async
203
206
  age_clock&.reset!
204
207
  end
205
208
  end
209
+ rescue => error
210
+ Console.error(self, "Error during child process management!", exception: error, running: @running)
206
211
  ensure
207
212
  delete(key, child)
208
213
  end
209
214
 
210
- if status.success?
215
+ if status&.success?
211
216
  Console.info(self, "Child exited successfully.", status: status, running: @running)
212
217
  else
213
218
  @statistics.failure!
@@ -220,9 +225,6 @@ module Async
220
225
  break
221
226
  end
222
227
  end
223
- rescue => error
224
- Console.error(self, "Failure during child process management!", exception: error, running: @running)
225
- raise
226
228
  ensure
227
229
  Console.info(self, "Child process management loop exited.", running: @running)
228
230
  end.resume
@@ -63,9 +63,9 @@ module Async
63
63
  # Formats the message using JSON and sends it to the parent controller.
64
64
  # This is suitable for use with {Channel}.
65
65
  def send(**message)
66
- data = ::JSON.dump(message)
66
+ data = ::JSON.dump(message) << "\n"
67
67
 
68
- @io.puts(data)
68
+ @io.write(data)
69
69
  @io.flush
70
70
  end
71
71
 
@@ -124,8 +124,8 @@ module Async
124
124
  # Initialize the thread.
125
125
  #
126
126
  # @parameter name [String] The name to use for the child thread.
127
- def initialize(name: nil)
128
- super()
127
+ def initialize(name: nil, **options)
128
+ super(**options)
129
129
 
130
130
  @status = nil
131
131
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Container
8
- VERSION = "0.27.4"
8
+ VERSION = "0.27.6"
9
9
  end
10
10
  end
data/license.md CHANGED
@@ -5,6 +5,7 @@ Copyright, 2019, by Yuji Yaginuma.
5
5
  Copyright, 2020, by Olle Jonsson.
6
6
  Copyright, 2020, by Juan Antonio Martín Lucas.
7
7
  Copyright, 2022, by Anton Sozontov.
8
+ Copyright, 2025, by Marc-André Cournoyer.
8
9
 
9
10
  Permission is hereby granted, free of charge, to any person obtaining a copy
10
11
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -26,6 +26,10 @@ 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.5
30
+
31
+ - Make the child handling more robust in the face of exceptions.
32
+
29
33
  ### v0.27.4
30
34
 
31
35
  - Fix race condition where `wait_for` could modify `@running` while it was being iterated over (`each_value`) during health checks.
@@ -64,10 +68,6 @@ Please see the [project releases](https://socketry.github.io/async-container/rel
64
68
 
65
69
  - [Add support for `NOTIFY_LOG` for Kubernetes readiness probes.](https://socketry.github.io/async-container/releases/index#add-support-for-notify_log-for-kubernetes-readiness-probes.)
66
70
 
67
- ### v0.21.0
68
-
69
- - Use `SIGKILL`/`Thread#kill` when the health check fails. In some cases, `SIGTERM` may not be sufficient to terminate a process because the signal can be ignored or the process may be in an uninterruptible state.
70
-
71
71
  ## Contributing
72
72
 
73
73
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Releases
2
2
 
3
+ ## v0.27.5
4
+
5
+ - Make the child handling more robust in the face of exceptions.
6
+
3
7
  ## v0.27.4
4
8
 
5
9
  - Fix race condition where `wait_for` could modify `@running` while it was being iterated over (`each_value`) during health checks.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.4
4
+ version: 0.27.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  - Olle Jonsson
9
9
  - Anton Sozontov
10
10
  - Juan Antonio Martín Lucas
11
+ - Marc-André Cournoyer
11
12
  - Yuji Yaginuma
12
13
  bindir: bin
13
14
  cert_chain:
metadata.gz.sig CHANGED
Binary file