Skip to content

Commit a4a3bc3

Browse files
GitHKAndrei Neagu
and
Andrei Neagu
authored
🐛 Fixes raises when stopping log fetching in dynamic-sidecar (#7302)
Co-authored-by: Andrei Neagu <[email protected]>
1 parent daf0b6a commit a4a3bc3

File tree

1 file changed

+9
-7
lines changed
  • services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core

1 file changed

+9
-7
lines changed

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core/docker_logs.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
"""
2-
BackgroundLogFetcher:
3-
Creates background task that
4-
reads every line of a container's log and
5-
posts it as a message to rabbit's log channel (logger)
2+
BackgroundLogFetcher:
3+
Creates background task that
4+
reads every line of a container's log and
5+
posts it as a message to rabbit's log channel (logger)
66
"""
77

8-
98
import logging
109
from asyncio import CancelledError, Task, create_task
10+
from collections.abc import AsyncGenerator, Callable, Coroutine
1111
from contextlib import suppress
12-
from typing import Any, AsyncGenerator, Callable, Coroutine, cast
12+
from typing import Any, cast
1313

1414
from aiodocker import DockerError
1515
from fastapi import FastAPI
@@ -85,7 +85,9 @@ async def stop_log_fetching(self, container_name: str) -> None:
8585
return
8686

8787
task.cancel()
88-
with suppress(CancelledError):
88+
89+
# NOTE: sometime the docker engine causes a TimeoutError after the task is cancelled
90+
with suppress(CancelledError, TimeoutError):
8991
await task
9092

9193
logger.debug("Logs fetching stopped for container '%s'", container_name)

0 commit comments

Comments
 (0)