[Bugfix][Diffusion] Drop aborted request's orphaned async output (fix #6413) (#6439)

Signed-off-by: summer <128961079+zhang-keliang@users.noreply.github.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
summerandmultica-agent authored and GitHub committed 2026-09-23 16:58:46 +00:00
1 parent 1934d121e2
commit 7f867fb782
9 files changed
+969 -25

No files matched your search

+12 -3
View File
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM-Omni project
"""Helpers for resolving ``concurrent.futures.Future`` objects shared across threads."""
import concurrent.futures
@@ -10,18 +13,24 @@ logger = init_logger(__name__)
_ResultT = TypeVar("_ResultT")
def try_set_result(fut: concurrent.futures.Future[_ResultT], result: _ResultT) -> None:
def try_set_result(fut: concurrent.futures.Future[_ResultT], result: _ResultT) -> bool:
# fut may be cancelled concurrently (e.g. asyncio.wait_for timeout) between
# the caller's fut.done() check and this call; drop the late result instead
# of crashing the pump thread.
# of crashing the pump thread. Return whether the future was actually
# resolved so callers that need to mirror the terminal state elsewhere
# (e.g. record the id as dropped) can react to a lost delivery.
try:
fut.set_result(result)
except concurrent.futures.InvalidStateError:
logger.debug("Dropping late result for already-resolved/cancelled future")
return False
return True
def try_set_exception(fut: concurrent.futures.Future[Any], exc: BaseException) -> None:
def try_set_exception(fut: concurrent.futures.Future[Any], exc: BaseException) -> bool:
try:
fut.set_exception(exc)
except concurrent.futures.InvalidStateError:
logger.debug("Dropping late exception for already-resolved/cancelled future")
return False
return True