Skip to content

Commit 1385273

Browse files
Add timeout params for REPL
1 parent 33910a7 commit 1385273

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ds_pycontain/python_dockerized_repl.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def __init__(
7474
port: int = 7123,
7575
image: Optional[DockerImage] = None,
7676
base_image: str = "python:3.11-alpine3.18",
77+
docker_startup_timeout: float = 300.0,
78+
repl_startup_timeout: float = 3.0,
7779
**kwargs: Dict[str, Any],
7880
) -> None:
7981
"""Starts docker container with python REPL server and wait till it
@@ -89,6 +91,8 @@ def __init__(
8991
:param port: port to use for the python REPL server.
9092
:param image: docker image to use for the container.
9193
:param base_image: base image to use for the docker image.
94+
:param docker_startup_timeout: timeout in seconds to wait for docker container to start.
95+
:param repl_startup_timeout: timeout in seconds to wait for REPL server to start.
9296
:param kwargs: additional params to pass to DockerContainer constructor.
9397
"""
9498
# for now use the image we created.
@@ -105,8 +109,8 @@ def __init__(
105109
# we need to ensure container is running and REPL server is
106110
# ready to accept requests, otherwise we might get connection
107111
# refused due to race conditions.
108-
self._wait_for_container_running()
109-
self._wait_for_repl_ready()
112+
self._wait_for_container_running(timeout=docker_startup_timeout)
113+
self._wait_for_repl_ready(timeout=repl_startup_timeout)
110114

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

0 commit comments

Comments
 (0)