From 84074b19aa08e79e342e8dc552d1dbd221693a81 Mon Sep 17 00:00:00 2001 From: Dramelac Date: Mon, 14 Oct 2024 20:05:57 +0200 Subject: [PATCH] Fix startup log timeout --- exegol/model/ExegolContainer.py | 2 +- exegol/utils/ContainerLogStream.py | 14 +++++--------- exegol/utils/DockerUtils.py | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/exegol/model/ExegolContainer.py b/exegol/model/ExegolContainer.py index bf3b108a..a3050d3e 100644 --- a/exegol/model/ExegolContainer.py +++ b/exegol/model/ExegolContainer.py @@ -118,7 +118,7 @@ def __start_container(self): :return: """ with console.status(f"Waiting to start {self.name}", spinner_style="blue") as progress: - start_date = datetime.utcnow() + start_date = datetime.now() try: self.__container.start() except APIError as e: diff --git a/exegol/utils/ContainerLogStream.py b/exegol/utils/ContainerLogStream.py index 51b278f8..f5dc6b30 100644 --- a/exegol/utils/ContainerLogStream.py +++ b/exegol/utils/ContainerLogStream.py @@ -1,12 +1,8 @@ -import asyncio -import concurrent.futures -import threading import time from datetime import datetime, timedelta -from typing import Union, List, Any, Optional +from typing import Optional from docker.models.containers import Container -from docker.types import CancellableStream from exegol.utils.ExeLog import logger @@ -17,7 +13,7 @@ def __init__(self, container: Container, start_date: Optional[datetime] = None, # Container to extract logs from self.__container = container # Fetch more logs from this datetime - self.__start_date: datetime = datetime.utcnow() if start_date is None else start_date + self.__start_date: datetime = datetime.now() if start_date is None else start_date self.__since_date = self.__start_date self.__until_date: Optional[datetime] = None # The data stream is returned from the docker SDK. It can contain multiple line at the same. @@ -30,7 +26,7 @@ def __init__(self, container: Container, start_date: Optional[datetime] = None, # Hint message flag self.__tips_sent = False - self.__tips_timedelta = self.__start_date + timedelta(seconds=15) + self.__tips_timedelta = self.__start_date + timedelta(seconds=30) def __iter__(self): return self @@ -38,7 +34,7 @@ def __iter__(self): def __next__(self): """Get the next line of the stream""" if self.__until_date is None: - self.__until_date = datetime.utcnow() + self.__until_date = datetime.now() while True: # The data stream is fetch from the docker SDK once empty. if self.__data_stream is None: @@ -69,4 +65,4 @@ def __next__(self): self.__data_stream = None self.__since_date = self.__until_date time.sleep(0.5) # Wait for more logs - self.__until_date = datetime.utcnow() + self.__until_date = datetime.now() diff --git a/exegol/utils/DockerUtils.py b/exegol/utils/DockerUtils.py index 6b932ab1..5cd512c2 100644 --- a/exegol/utils/DockerUtils.py +++ b/exegol/utils/DockerUtils.py @@ -603,7 +603,7 @@ def buildImage(self, tag: str, build_profile: Optional[str] = None, build_docker tag=f"{ConstantConfig.IMAGE_NAME}:{tag}", buildargs={"TAG": f"{build_profile}", "VERSION": "local", - "BUILD_DATE": datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ')}, + "BUILD_DATE": datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')}, platform="linux/" + ParametersManager().arch, rm=True, forcerm=True,