Skip to content

Commit 7c73121

Browse files
committed
add timeout to prevent hanging
1 parent 6236c7b commit 7c73121

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

nucleus/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
)
9393
from .constants import (
9494
NUCLEUS_ENDPOINT,
95+
DEFAULT_TIMEOUT,
9596
ERRORS_KEY,
9697
ERROR_ITEMS,
9798
ERROR_PAYLOAD,
@@ -1021,6 +1022,7 @@ def _make_grequest(
10211022
session=sess,
10221023
files=payload,
10231024
auth=(self.api_key, ""),
1025+
timeout=DEFAULT_TIMEOUT,
10241026
)
10251027
else:
10261028
post = requests_command(
@@ -1029,6 +1031,7 @@ def _make_grequest(
10291031
json=payload,
10301032
headers={"Content-Type": "application/json"},
10311033
auth=(self.api_key, ""),
1034+
timeout=DEFAULT_TIMEOUT,
10321035
)
10331036
return post
10341037

@@ -1052,6 +1055,7 @@ def _make_request_raw(
10521055
json=payload,
10531056
headers={"Content-Type": "application/json"},
10541057
auth=(self.api_key, ""),
1058+
timeout=DEFAULT_TIMEOUT,
10551059
)
10561060
logger.info("API request has response code %s", response.status_code)
10571061

nucleus/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
NUCLEUS_ENDPOINT = "https://api.scale.com/v1/nucleus"
2+
DEFAULT_TIMEOUT = 30
23
ITEMS_KEY = "items"
34
ITEM_KEY = "item"
45
REFERENCE_ID_KEY = "reference_id"

0 commit comments

Comments
 (0)