diff --git a/pennylane_ionq/api_client.py b/pennylane_ionq/api_client.py index 9c09812..08f9365 100644 --- a/pennylane_ionq/api_client.py +++ b/pennylane_ionq/api_client.py @@ -129,6 +129,9 @@ def __init__(self, **kwargs): self.HEADERS = {"User-Agent": self.USER_AGENT} + # Ten minute timeout on requests. + self.TIMEOUT_SECONDS = 60 * 10 + if self.AUTHENTICATION_TOKEN: self.set_authorization_header(self.AUTHENTICATION_TOKEN) else: @@ -179,6 +182,8 @@ def request(self, method, **params): params["headers"] = self.HEADERS + params["timeout"] = self.TIMEOUT_SECONDS + try: response = method(**params) except Exception as e: diff --git a/tests/test_api_client.py b/tests/test_api_client.py index d317712..6a82c06 100755 --- a/tests/test_api_client.py +++ b/tests/test_api_client.py @@ -113,6 +113,7 @@ def test_init_default_client(self): client = api_client.APIClient(authentication_token="") assert client.BASE_URL.startswith("https://") assert client.HEADERS["User-Agent"] == client.USER_AGENT + assert client.TIMEOUT_SECONDS == 600 def test_set_authorization_header(self): """