Skip to content

Commit a9923a3

Browse files
committed
add time out parameters
1 parent 3bdade8 commit a9923a3

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

knime_extension/src/nodes/opendata.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,14 @@ class SocrataSearchNode:
923923
default_value="Massachusetts",
924924
)
925925

926+
timeout = knext.IntParameter(
927+
label="Request timeout in seconds",
928+
description="The timeout in seconds for the request API.",
929+
default_value=120,
930+
min_value=1,
931+
is_advanced=True,
932+
)
933+
926934
def configure(self, configure_context):
927935
# TODO Create combined schema
928936
return None
@@ -940,7 +948,7 @@ def execute(self, exec_context: knext.ExecutionContext):
940948
f"http://api.us.socrata.com/api/catalog/v1?q={encoded_query_item}&only=datasets&limit=10000"
941949
)
942950

943-
response = urlopen(request)
951+
response = urlopen(request, timeout=self.timeout)
944952
response_body = response.read()
945953

946954
# Load the JSON response into a Python dictionary
@@ -1043,7 +1051,15 @@ class SocrataDataNode:
10431051
default_value="",
10441052
)
10451053

1046-
def configure(self, configure_context):
1054+
timeout = knext.IntParameter(
1055+
label="Request timeout in seconds",
1056+
description="The timeout in seconds for the request API.",
1057+
default_value=120,
1058+
min_value=1,
1059+
is_advanced=True,
1060+
)
1061+
1062+
def configure(self, configure_context, input_schema_1):
10471063
# TODO Create combined schema
10481064
return None
10491065

@@ -1056,6 +1072,7 @@ def execute(self, exec_context: knext.ExecutionContext):
10561072
# Unauthenticated client only works with public data sets. Note 'None'
10571073
# in place of application token, and no username or password:
10581074
client = Socrata(self.metadata_domain, None)
1075+
client.timeout = self.timeout
10591076
limit = 100000
10601077
offset = 0
10611078
all_results = []

0 commit comments

Comments
 (0)