From 3f2afc7ced810c6aa5b953db84dc087d00379a04 Mon Sep 17 00:00:00 2001 From: Victor Skvortsov Date: Wed, 25 Mar 2026 13:19:44 +0500 Subject: [PATCH] Handle TimeoutError on pipeline draining --- .../_internal/server/background/pipeline_tasks/base.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/dstack/_internal/server/background/pipeline_tasks/base.py b/src/dstack/_internal/server/background/pipeline_tasks/base.py index 76073b789..b37940ad1 100644 --- a/src/dstack/_internal/server/background/pipeline_tasks/base.py +++ b/src/dstack/_internal/server/background/pipeline_tasks/base.py @@ -124,8 +124,13 @@ async def drain(self): raise PipelineError("Cannot drain running pipeline. Call `shutdown()` first.") results = await asyncio.gather(*self._tasks, return_exceptions=True) for task, result in zip(self._tasks, results): - if isinstance(result, BaseException) and not isinstance( - result, asyncio.CancelledError + if ( + isinstance(result, BaseException) + and not isinstance(result, asyncio.CancelledError) + and not isinstance( + result, + asyncio.TimeoutError, # At least on Python 3.9 a task may raise TimeoutError from CancelledError. + ) ): logger.error( "Unexpected exception when draining pipeline task %r",