async-container 0.35.0 → 0.36.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: 047d770adce55a53f648a828ac9e1b4694598d8815d06c271cb293b31829ac90
4
- data.tar.gz: d54a1bda7d25bd2d33b72c62ea0722a8c82a3a68045b1cae529ed149d37e5ea8
3
+ metadata.gz: 0b7c79f742eb9268bd10341606d71dcb98855a5112ba7022d35a38618185c3ea
4
+ data.tar.gz: 37a766f7e70db3d39ae22af3a4c1e0edfc92470f7d34bc0030791d3f23d8feea
5
5
  SHA512:
6
- metadata.gz: 5175d784347c33381f3014ce30845448890b6074ddb606861877fb23937a1afcdf0d776dd70d5f700498de4b09e59560936b78f59d0b3b2f2bf9b96d132efa24
7
- data.tar.gz: c5e130f7dd4723935e9ae95f3aebb63dcea17aba57c2a995a5bb5ac4085973e63b5c1bf3dfb79d9ea79dd20b3a017be9b7f38937babe4f09ac7c6135f44f7300
6
+ metadata.gz: 6d538e1db3f7483707fb77b7012b293eb51e89ae7c25be6f8af738e0e5ae0f43528c2e437a322f1180fe12425560280341428e5b4264eeacda2396766b687c46
7
+ data.tar.gz: 2f405c30b3037e15c132e390bb3df865a2bfbe191d665511d9321c4ef0777245ef6146f914134addfece8fc0b279f194621bfd70c1952738b0c6e5bb461ecac8
checksums.yaml.gz.sig CHANGED
Binary file
@@ -101,23 +101,25 @@ module Async
101
101
  def self.fork(**options)
102
102
  # $stderr.puts fork: caller
103
103
  self.new(**options) do |process|
104
- ::Process.fork do
105
- # We use `Thread.current.raise(...)` so that exceptions are filtered through `Thread.handle_interrupt` correctly.
106
- Signal.trap(:INT){::Thread.current.raise(Interrupt)}
107
- Signal.trap(:TERM){::Thread.current.raise(Interrupt)} # Same as SIGINT.
108
- Signal.trap(:HUP){::Thread.current.raise(Restart)}
109
-
110
- # This could be a configuration option:
111
- ::Thread.handle_interrupt(SignalException => :immediate) do
112
- yield Instance.for(process)
113
- rescue Interrupt
114
- # Graceful exit.
115
- rescue Exception => error
116
- Console.error(self, error)
104
+ ::Thread.new do
105
+ ::Process.fork do
106
+ # We use `Thread.current.raise(...)` so that exceptions are filtered through `Thread.handle_interrupt` correctly.
107
+ Signal.trap(:INT){::Thread.current.raise(Interrupt)}
108
+ Signal.trap(:TERM){::Thread.current.raise(Interrupt)} # Same as SIGINT.
109
+ Signal.trap(:HUP){::Thread.current.raise(Restart)}
117
110
 
118
- exit!(1)
111
+ # This could be a configuration option:
112
+ ::Thread.handle_interrupt(SignalException => :immediate) do
113
+ yield Instance.for(process)
114
+ rescue Interrupt
115
+ # Graceful exit.
116
+ rescue Exception => error
117
+ Console.error(self, error)
118
+
119
+ exit!(1)
120
+ end
119
121
  end
120
- end
122
+ end.value
121
123
  end
122
124
  end
123
125
 
@@ -117,6 +117,10 @@ module Async
117
117
 
118
118
  # Gracefully interrupt all child instances.
119
119
  def interrupt
120
+ # We must enter the stopping state before signalling the children. Interrupting a child causes it to drain and exit, but the main run loop will respawn any child that exits while `restart: true` and the container is not stopping (see the `restart && !@stopping` gate in `#run`). Without setting this flag, an interrupted child immediately respawns, so the container never drains and `#wait` never returns.
121
+ #
122
+ # This matters most for `Hybrid` containers: a `SIGINT`/`SIGTERM` delivered to a fork is translated into a call to `#interrupt` on the inner threaded container, which typically runs with `restart: true` (the default for `async-service` managed services). If `#interrupt` did not set this flag, the inner threads would drain, exit, and respawn in a loop, so a single signal would never terminate the fork. Setting `@stopping = true` here makes `#interrupt` behave as the start of a graceful shutdown: children drain and exit, are not respawned, and the fork terminates - consistent with how `Forked` and `Threaded` containers handle a single interrupt.
123
+ @stopping = true
120
124
  @group.interrupt
121
125
  end
122
126
 
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module Container
8
- VERSION = "0.35.0"
8
+ VERSION = "0.36.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.36.0
32
+
33
+ - Forked containers now fork child processes from a short-lived thread, reducing inherited scheduler and parent stack state in children.
34
+
35
+ ### v0.35.1
36
+
37
+ - **Fixed**: `Hybrid` container now stops on interrupt instead of restarting indefinitely.
38
+
31
39
  ### v0.35.0
32
40
 
33
41
  - **Fixed**: `Hybrid` now interrupts inner threaded children during graceful shutdown and force-stops remaining children on exit.
@@ -60,17 +68,6 @@ Please see the [project releases](https://socketry.github.io/async-container/rel
60
68
 
61
69
  - Expose `Async::Container::Controller` `#notify`, `#container_class`, and `#graceful_stop` for testing.
62
70
 
63
- ### v0.32.0
64
-
65
- - Minor **breaking** changes to `Async::Container::Policy` interface.
66
- - Expose `Async::Container::Statistics::Rate#window`.
67
-
68
- ### v0.31.0
69
-
70
- - Introduce `Async::Container::Policy` for managing child lifecycle events and implementing custom failure handling strategies.
71
- - Add `Async::Container::Statistics::Rate` for tracking failure and restart rates over sliding time windows.
72
- - Fix restart counter to only increment when actually restarting (check `@running` flag).
73
-
74
71
  ## Contributing
75
72
 
76
73
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Releases
2
2
 
3
+ ## v0.36.0
4
+
5
+ - Forked containers now fork child processes from a short-lived thread, reducing inherited scheduler and parent stack state in children.
6
+
7
+ ## v0.35.1
8
+
9
+ - **Fixed**: `Hybrid` container now stops on interrupt instead of restarting indefinitely.
10
+
3
11
  ## v0.35.0
4
12
 
5
13
  - **Fixed**: `Hybrid` now interrupts inner threaded children during graceful shutdown and force-stops remaining children on exit.
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.35.0
4
+ version: 0.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file