Skip to content

Commit 4fba477

Browse files
added logging of attempt no. while attempting to connect to container (testcontainers#207)
* added logging of attempt no. while attempting to connect to container * Combine log statement in waiting utils retry. * Split line in waiting_utils for flake8 compliance. Co-authored-by: Till Hoffmann <tillahoffmann@gmail.com>
1 parent a2bc91e commit 4fba477

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

testcontainers/core/waiting_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ def wait_container_is_ready(*transient_exceptions):
4444
def wrapper(wrapped, instance, args, kwargs):
4545
exception = None
4646
logger.info("Waiting to be ready...")
47-
for _ in range(config.MAX_TRIES):
47+
for attempt_no in range(config.MAX_TRIES):
4848
try:
4949
return wrapped(*args, **kwargs)
5050
except transient_exceptions as e:
51-
logger.debug('container is not yet ready: %s', traceback.format_exc())
51+
logger.debug(f"Connection attempt '{attempt_no + 1}' of '{config.MAX_TRIES + 1}' "
52+
f"failed: {traceback.format_exc()}")
5253
time.sleep(config.SLEEP_TIME)
5354
exception = e
5455
raise TimeoutException(

0 commit comments

Comments
 (0)