From 5f7c73d099822983a82cc4695f8b80329961d5c7 Mon Sep 17 00:00:00 2001 From: Andrei Neagu Date: Tue, 4 Mar 2025 10:18:43 +0100 Subject: [PATCH 1/2] fixes issue task cancellation --- .../core/docker_logs.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/docker_logs.py b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/docker_logs.py index 1033ec53f37..b4f08d4dd8b 100644 --- a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/docker_logs.py +++ b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/docker_logs.py @@ -1,15 +1,15 @@ """ - BackgroundLogFetcher: - Creates background task that - reads every line of a container's log and - posts it as a message to rabbit's log channel (logger) +BackgroundLogFetcher: + Creates background task that + reads every line of a container's log and + posts it as a message to rabbit's log channel (logger) """ - import logging from asyncio import CancelledError, Task, create_task +from collections.abc import AsyncGenerator, Callable, Coroutine from contextlib import suppress -from typing import Any, AsyncGenerator, Callable, Coroutine, cast +from typing import Any, cast from aiodocker import DockerError from fastapi import FastAPI @@ -85,7 +85,7 @@ async def stop_log_fetching(self, container_name: str) -> None: return task.cancel() - with suppress(CancelledError): + with suppress(CancelledError, TimeoutError): await task logger.debug("Logs fetching stopped for container '%s'", container_name) From 26936298c09bce00786a65d1581ec108d5e71b1a Mon Sep 17 00:00:00 2001 From: Andrei Neagu <5694077+GitHK@users.noreply.github.com> Date: Thu, 6 Mar 2025 11:10:01 +0100 Subject: [PATCH 2/2] added note --- .../src/simcore_service_dynamic_sidecar/core/docker_logs.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/docker_logs.py b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/docker_logs.py index b4f08d4dd8b..668ba0db91f 100644 --- a/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/docker_logs.py +++ b/services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/docker_logs.py @@ -85,6 +85,8 @@ async def stop_log_fetching(self, container_name: str) -> None: return task.cancel() + + # NOTE: sometime the docker engine causes a TimeoutError after the task is cancelled with suppress(CancelledError, TimeoutError): await task