From 245e0a16c9bc9ea6e806b83b007f1c6d838d4b03 Mon Sep 17 00:00:00 2001 From: Ulrich Moshammer-Mischkof Date: Thu, 4 Sep 2025 20:00:51 +1000 Subject: [PATCH] #34: updated api.py send_api_request to pass the timeout parameter to the urlopen function instead of the Request object. --- zabbix_utils/api.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/zabbix_utils/api.py b/zabbix_utils/api.py index c3ae9ad..aa28b0b 100644 --- a/zabbix_utils/api.py +++ b/zabbix_utils/api.py @@ -347,7 +347,7 @@ def send_api_request(self, method: str, params: Optional[dict] = None, headers=headers, method='POST' ) - req.timeout = self.timeout + # Disable SSL certificate validation if needed. if not self.validate_certs: @@ -360,7 +360,10 @@ def send_api_request(self, method: str, params: Optional[dict] = None, ctx = None try: - resp = ul.urlopen(req, context=ctx) + if self.timeout: + resp = ul.urlopen(req, context=ctx, timeout=self.timeout) + else: + resp = ul.urlopen(req, context=ctx) resp_json = json.loads(resp.read().decode('utf-8')) except URLError as err: raise ProcessingError(f"Unable to connect to {self.url}:", err) from None