diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d3a9d236..0bcbc582c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Fix + +- When testing connection, set timeout to 10s when checking if port is opened. + ## [7.0.2] 2024-09-13 ### Changed diff --git a/toucan_connectors/toucan_connector.py b/toucan_connectors/toucan_connector.py index e48d2b507..71b5bcea6 100644 --- a/toucan_connectors/toucan_connector.py +++ b/toucan_connectors/toucan_connector.py @@ -26,6 +26,8 @@ if TYPE_CHECKING: # pragma: no cover import pandas as pd +TIMEOUT_CHECK_PORT = 10 # consider port closed if > 10 seconds + LOGGER = logging.getLogger(__name__) @@ -383,6 +385,7 @@ def check_hostname(hostname): @staticmethod def check_port(host, port): with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: + s.settimeout(TIMEOUT_CHECK_PORT) s.connect((host, port)) def get_status(self) -> ConnectorStatus: