async-container 0.36.0 → 0.38.0

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: 0b7c79f742eb9268bd10341606d71dcb98855a5112ba7022d35a38618185c3ea
4
- data.tar.gz: 37a766f7e70db3d39ae22af3a4c1e0edfc92470f7d34bc0030791d3f23d8feea
3
+ metadata.gz: 2afc84589d803bb2b4205a0da9397039659626c90e88b6b530cba4e1f1e51414
4
+ data.tar.gz: 8f1d086baf92d980511ed2f7ce1e165a32bd92aec8302673ee67489200e87519
5
5
  SHA512:
6
- metadata.gz: 6d538e1db3f7483707fb77b7012b293eb51e89ae7c25be6f8af738e0e5ae0f43528c2e437a322f1180fe12425560280341428e5b4264eeacda2396766b687c46
7
- data.tar.gz: 2f405c30b3037e15c132e390bb3df865a2bfbe191d665511d9321c4ef0777245ef6146f914134addfece8fc0b279f194621bfd70c1952738b0c6e5bb461ecac8
6
+ metadata.gz: 8c3bf95bc47ca93403e14f6c517f77f1b7c48f033d63e451fd6ee7f731b793d6220cff578cda76446055badb75281ea9517f3da26c4abae4cb49e6a87a275e5b
7
+ data.tar.gz: ca937e711802c41d6f397d02e267308b5123385369e739b52fd6cda74aca3f3a4af1f9d0d12643759ee325db76e8247f6fd1b35741b4b592200086dfc5f22c90
checksums.yaml.gz.sig CHANGED
Binary file
@@ -12,6 +12,18 @@ require_relative "policy"
12
12
 
13
13
  module Async
14
14
  module Container
15
+ # The default graceful stop policy for controllers.
16
+ GRACEFUL_STOP = ENV.fetch("ASYNC_CONTAINER_GRACEFUL_STOP", "true").then do |value|
17
+ case value
18
+ when "true"
19
+ true # Default timeout for graceful termination.
20
+ when "false"
21
+ false # Immediately kill the processes.
22
+ else
23
+ value.to_f
24
+ end
25
+ end
26
+
15
27
  # Manages the life-cycle of one or more containers in order to support a persistent system.
16
28
  # e.g. a web server, job server or some other long running system.
17
29
  class Controller
@@ -23,7 +35,7 @@ module Async
23
35
 
24
36
  # Initialize the controller.
25
37
  # @parameter notify [Notify::Client] A client used for process readiness notifications.
26
- def initialize(notify: Notify.open!, container_class: Container, graceful_stop: true)
38
+ def initialize(notify: Notify.open!, container_class: Container, graceful_stop: GRACEFUL_STOP)
27
39
  @notify = notify
28
40
  @container_class = container_class
29
41
  @graceful_stop = graceful_stop
@@ -101,7 +101,8 @@ module Async
101
101
  def self.fork(**options)
102
102
  # $stderr.puts fork: caller
103
103
  self.new(**options) do |process|
104
- ::Thread.new do
104
+ # CRuby makes the currently executing fiber the root fiber in the child process and clears its resuming fiber, so the caller's stack can be collected without forking from a separate native thread:
105
+ ::Fiber.new(blocking: true) do
105
106
  ::Process.fork do
106
107
  # We use `Thread.current.raise(...)` so that exceptions are filtered through `Thread.handle_interrupt` correctly.
107
108
  Signal.trap(:INT){::Thread.current.raise(Interrupt)}
@@ -119,7 +120,7 @@ module Async
119
120
  exit!(1)
120
121
  end
121
122
  end
122
- end.value
123
+ end.resume
123
124
  end
124
125
  end
125
126
 
@@ -10,19 +10,7 @@ require_relative "error"
10
10
 
11
11
  module Async
12
12
  module Container
13
- # The default timeout for terminating processes, before escalating to killing.
14
- GRACEFUL_TIMEOUT = ENV.fetch("ASYNC_CONTAINER_GRACEFUL_TIMEOUT", "true").then do |value|
15
- case value
16
- when "true"
17
- true # Default timeout for graceful termination.
18
- when "false"
19
- false # Immediately kill the processes.
20
- else
21
- value.to_f
22
- end
23
- end
24
-
25
- # The default timeout for graceful termination.
13
+ # The default timeout for graceful termination, used when the `graceful` argument is true.
26
14
  DEFAULT_GRACEFUL_TIMEOUT = 10.0
27
15
 
28
16
  # Manages a group of running processes.
@@ -163,7 +151,7 @@ module Async
163
151
  # If `graceful` is false, skip the SIGINT phase and go directly to SIGKILL.
164
152
  #
165
153
  # @parameter graceful [Boolean | Numeric] Whether to send SIGINT first or skip directly to SIGKILL.
166
- def stop(graceful = GRACEFUL_TIMEOUT)
154
+ def stop(graceful = true)
167
155
  Console.debug(self, "Stopping all processes...", graceful: graceful)
168
156
 
169
157
  # If a timeout is specified, interrupt the children first:
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2025, by Samuel Williams.
4
+ # Copyright, 2019-2026, by Samuel Williams.
5
5
  # Copyright, 2022, by Anton Sozontov.
6
6
 
7
7
  require_relative "forked"
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Container
8
- VERSION = "0.36.0"
8
+ VERSION = "0.38.0"
9
9
  end
10
10
  end
data/readme.md CHANGED
@@ -28,6 +28,14 @@ Please see the [project documentation](https://socketry.github.io/async-containe
28
28
 
29
29
  Please see the [project releases](https://socketry.github.io/async-container/releases/index) for all releases.
30
30
 
31
+ ### v0.38.0
32
+
33
+ - Fork child processes from a clean fiber stack rather than a short-lived native thread, preserving child garbage collection while improving compatibility with native libraries.
34
+
35
+ ### v0.37.0
36
+
37
+ - Rename `ASYNC_CONTAINER_GRACEFUL_TIMEOUT` to `ASYNC_CONTAINER_GRACEFUL_STOP` and apply it at the controller level as `GRACEFUL_STOP`. `Group#stop` now only applies the shutdown policy it is given.
38
+
31
39
  ### v0.36.0
32
40
 
33
41
  - Forked containers now fork child processes from a short-lived thread, reducing inherited scheduler and parent stack state in children.
@@ -60,14 +68,6 @@ Please see the [project releases](https://socketry.github.io/async-container/rel
60
68
 
61
69
  - Add `Async::Container::Generic#stopping?` so that policies can more accurately track the state of the container.
62
70
 
63
- ### v0.33.0
64
-
65
- - Add `Policy#make_statistics` to allow policies to customize statistics initialization.
66
-
67
- ### v0.32.1
68
-
69
- - Expose `Async::Container::Controller` `#notify`, `#container_class`, and `#graceful_stop` for testing.
70
-
71
71
  ## Contributing
72
72
 
73
73
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Releases
2
2
 
3
+ ## v0.38.0
4
+
5
+ - Fork child processes from a clean fiber stack rather than a short-lived native thread, preserving child garbage collection while improving compatibility with native libraries.
6
+
7
+ ## v0.37.0
8
+
9
+ - Rename `ASYNC_CONTAINER_GRACEFUL_TIMEOUT` to `ASYNC_CONTAINER_GRACEFUL_STOP` and apply it at the controller level as `GRACEFUL_STOP`. `Group#stop` now only applies the shutdown policy it is given.
10
+
3
11
  ## v0.36.0
4
12
 
5
13
  - Forked containers now fork child processes from a short-lived thread, reducing inherited scheduler and parent stack state in children.
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.36.0
4
+ version: 0.38.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -49,14 +49,14 @@ dependencies:
49
49
  requirements:
50
50
  - - "~>"
51
51
  - !ruby/object:Gem::Version
52
- version: '2.22'
52
+ version: '2.44'
53
53
  type: :runtime
54
54
  prerelease: false
55
55
  version_requirements: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '2.22'
59
+ version: '2.44'
60
60
  executables: []
61
61
  extensions: []
62
62
  extra_rdoc_files: []
metadata.gz.sig CHANGED
Binary file