Skip to content

Commit

Permalink
Fix startup log timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Dramelac committed Oct 14, 2024
1 parent bf1d6f5 commit 84074b1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion exegol/model/ExegolContainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 5 additions & 9 deletions exegol/utils/ContainerLogStream.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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.
Expand All @@ -30,15 +26,15 @@ 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

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:
Expand Down Expand Up @@ -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()
2 changes: 1 addition & 1 deletion exegol/utils/DockerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 84074b1

Please sign in to comment.