From 54bd2e417c6befbf01249c494d3605d2e0a6259c Mon Sep 17 00:00:00 2001 From: gdm85 Date: Wed, 20 Jul 2022 17:28:33 -0700 Subject: [PATCH] Log an error for every failed attempt to connect to master The connection timeout and number of attempts are hardcoded, so a failure will take very long These log lines will allow to troubleshoot issues with the connection to master --- locust/runners.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/locust/runners.py b/locust/runners.py index 778bbe1fa7..b2f385d591 100644 --- a/locust/runners.py +++ b/locust/runners.py @@ -1336,6 +1336,10 @@ def connect_to_master(self): self.client.send(Message("client_ready", __version__, self.client_id)) success = self.connection_event.wait(timeout=CONNECT_TIMEOUT) if not success: + if self.retry < 3: + logger.debug(f"Failed to connect to master {self.master_host}:{self.master_port}, retry {self.retry}/{CONNECT_RETRY_COUNT}.") + else: + logger.warning(f"Failed to connect to master {self.master_host}:{self.master_port}, retry {self.retry}/{CONNECT_RETRY_COUNT}.") if self.retry > CONNECT_RETRY_COUNT: raise ConnectionError() self.connect_to_master()