Skip to content

Commit

Permalink
Merge pull request #177 from akretion/add-timeout
Browse files Browse the repository at this point in the history
Add timeout to webservices call to avoid waiting indefinitly
  • Loading branch information
florian-dacosta authored Oct 23, 2024
2 parents 22adbb0 + f90f177 commit 623289c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions roulier/carriers/geodis_fr/geodis_transport_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 6 additions & 2 deletions roulier/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 623289c

Please sign in to comment.