Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add timeout to webservices call to avoid waiting indefinitly #177

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading