From f90f177bd0a1bae6c1744266a1124aa17bcbc0fc Mon Sep 17 00:00:00 2001 From: Florian da Costa Date: Wed, 24 Jul 2024 11:29:44 +0200 Subject: [PATCH] Add timeout to webservices call to avoid waiting indefinitly --- roulier/carriers/geodis_fr/geodis_transport_rest.py | 1 + roulier/transport.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/roulier/carriers/geodis_fr/geodis_transport_rest.py b/roulier/carriers/geodis_fr/geodis_transport_rest.py index 617139a..f83bfbe 100644 --- a/roulier/carriers/geodis_fr/geodis_transport_rest.py +++ b/roulier/carriers/geodis_fr/geodis_transport_rest.py @@ -63,6 +63,7 @@ def send_request(self, body, token): ws_url, headers={"X-GEODIS-Service": token}, data=body, + timeout=30, ) def handle_500(self, response): diff --git a/roulier/transport.py b/roulier/transport.py index 578e522..937e4bc 100755 --- a/roulier/transport.py +++ b/roulier/transport.py @@ -54,9 +54,13 @@ def _get_requests_url(self, payload=None): return self.config.ws_test_url return self.config.ws_url - def send_request(self, body, url, auth=None, headers=None, method="post", **kwargs): + def send_request( + self, body, url, auth=None, headers=None, method="post", timeout=30, **kwargs + ): send = getattr(requests, method) - return send(url, headers=headers, auth=auth, data=body, **kwargs) + return send( + url, headers=headers, auth=auth, data=body, timeout=timeout, **kwargs + ) @abstractmethod def handle_200(self, response):