Skip to content

Commit

Permalink
Add timeout params for REPL
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-grodek-dsai committed Nov 6, 2023
1 parent 33910a7 commit 1385273
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/ds_pycontain/python_dockerized_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def __init__(
port: int = 7123,
image: Optional[DockerImage] = None,
base_image: str = "python:3.11-alpine3.18",
docker_startup_timeout: float = 300.0,
repl_startup_timeout: float = 3.0,
**kwargs: Dict[str, Any],
) -> None:
"""Starts docker container with python REPL server and wait till it
Expand All @@ -89,6 +91,8 @@ def __init__(
:param port: port to use for the python REPL server.
:param image: docker image to use for the container.
:param base_image: base image to use for the docker image.
:param docker_startup_timeout: timeout in seconds to wait for docker container to start.
:param repl_startup_timeout: timeout in seconds to wait for REPL server to start.
:param kwargs: additional params to pass to DockerContainer constructor.
"""
# for now use the image we created.
Expand All @@ -105,8 +109,8 @@ def __init__(
# we need to ensure container is running and REPL server is
# ready to accept requests, otherwise we might get connection
# refused due to race conditions.
self._wait_for_container_running()
self._wait_for_repl_ready()
self._wait_for_container_running(timeout=docker_startup_timeout)
self._wait_for_repl_ready(timeout=repl_startup_timeout)

def _wait_for_container_running(self, timeout: float = 3.0) -> None:
"""Sleep until container is running or timeout is reached.
Expand Down

0 comments on commit 1385273

Please sign in to comment.