Deleting a live flow ends the calls it has out on workers and drops what a removed node still returns, so a node that never returns gives its slot and process back and a late answer no longer recreates the flow's values; a cancel goes through the call's own inbox and is sent after the call's frame, so a service stopped right after starting no longer cancels before its serve
This commit is contained in:
@@ -10,6 +10,7 @@ from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import queue
|
||||
import shlex
|
||||
import uuid
|
||||
from collections.abc import Iterable
|
||||
@@ -169,9 +170,12 @@ class ServiceNode(Node):
|
||||
"env": self.cfg.env,
|
||||
"weights": self.cfg.weights,
|
||||
}
|
||||
# On a thread, as every call is, and holding no slot.
|
||||
# On a thread, as every call is, and holding no slot. Its inbox is made
|
||||
# here, so a stop that comes before the thread has sent the serve can
|
||||
# still end it, after the serve rather than ahead of it.
|
||||
inbox: queue.Queue[dict[str, Any] | None] = queue.Queue()
|
||||
call = asyncio.ensure_future(
|
||||
asyncio.to_thread(worker.request, payload, 0, slot=False)
|
||||
asyncio.to_thread(worker.request, payload, 0, slot=False, inbox=inbox)
|
||||
)
|
||||
# Retrieved however it ends, so one that outlives a stop is not
|
||||
# reported at exit.
|
||||
@@ -197,7 +201,7 @@ class ServiceNode(Node):
|
||||
# The flow stopped, or this side failed. Ending the call kills
|
||||
# the server's process group on the worker, and its answer says
|
||||
# that is done, so the next start finds the port free.
|
||||
await asyncio.to_thread(worker.cancel, call_id)
|
||||
inbox.put(worker.END)
|
||||
await asyncio.wait({call}, timeout=STOP_WAIT_S)
|
||||
await asyncio.to_thread(self._withdraw)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user