You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/async/container/generic.rb
+25-5Lines changed: 25 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -144,8 +144,7 @@ def wait_until_ready
144
144
end
145
145
end
146
146
147
-
self.sleep
148
-
147
+
# Check readiness before sleeping: after a reload that only reuses or removes children, no new child sends a readiness message, so `sleep` would otherwise block indefinitely even though everything is already ready.
# Any keyed child which is not re-marked during {yield} is considered obsolete and is
333
+
# stopped. Its supervising fiber removes it from {@keyed} once it has exited.
334
+
#
335
+
# @returns [Boolean] Whether any keyed instances were stopped.
330
336
defreload
331
337
@keyed.each_value(&:clear!)
332
338
333
339
yield
334
340
335
341
dirty=false
336
342
337
-
@keyed.delete_ifdo |key,value|
338
-
value.stop? && (dirty=true)
343
+
# Snapshot the values so we can stop obsolete children without mutating `@keyed` mid-iteration (the supervising fiber deletes the entry when the child exits):
344
+
@keyed.values.eachdo |keyed|
345
+
unlesskeyed.marked?
346
+
stop_child(keyed.value)
347
+
dirty=true
348
+
end
339
349
end
340
350
341
351
returndirty
342
352
end
343
353
354
+
# Stop a single child instance and prevent it from being restarted.
355
+
# @parameter child [Channel] The child instance to stop.
356
+
# @parameter graceful [Boolean | Numeric] Whether to stop the child gracefully.
357
+
defstop_child(child,graceful=true)
358
+
# Prevent the supervising fiber from restarting the child once it exits:
359
+
child.stopping!
360
+
361
+
@group.stop_child(child,graceful)
362
+
end
363
+
344
364
# Mark the container's keyed instance which ensures that it won't be discarded.
Copy file name to clipboardExpand all lines: releases.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,9 @@
1
1
# Releases
2
2
3
+
## Unreleased
4
+
5
+
-**Fixed**: Reloading a container now correctly stops keyed children whose keys are no longer configured. Previously this raised `NoMethodError` (the child has no `stop` method) and would not have stopped `restart: true` children even if it had. `Generic#reload` now stops obsolete children via a new `Group#stop_child`, and a per-child stopping flag prevents them from being respawned.
6
+
3
7
## v0.37.0
4
8
5
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.
0 commit comments