Skip to content

Commit cef0744

Browse files
authored
Merge pull request #257 from oslokommune/handle-timeout
Handle request connection timeouts
2 parents 806196d + c83ff6c commit cef0744

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## ?.?.? - Unreleased
22

33
* Removed Origo as an organization choice for public services.
4+
* Improved request timeout handling.
45

56
## 6.0.0 - 2026-01-30
67

okdata/cli/__main__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from keycloak.exceptions import KeycloakGetError, KeycloakPostError
66
from okdata.sdk.exceptions import ApiAuthenticateError
7-
from requests.exceptions import RequestException
7+
from requests.exceptions import ConnectTimeout, RequestException
88

99
from okdata.cli import MAINTAINER
1010
from okdata.cli.command import BaseCommand
@@ -37,6 +37,11 @@ def main():
3737
# Flush output here to force SIGPIPE to be triggered while inside
3838
# this try block.
3939
sys.stdout.flush()
40+
except ConnectTimeout as e:
41+
instance.print(
42+
f"Connection to '{e.request.url}' timed out. Please try again, "
43+
f"or contact {MAINTAINER} if the problem persists.",
44+
)
4045
except RequestException as e:
4146
if hasattr(e.response, "json"):
4247
instance.print_error_response(e.response.json())

0 commit comments

Comments
 (0)