Skip to content

Commit 33cf933

Browse files
committed
Added timeout parameter to sparql query
1 parent 8d0ee9b commit 33cf933

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pymantic/sparql.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,16 @@ class _Select(_SelectOrUpdate):
102102
'text/turtle',
103103
]
104104

105-
def __init__(self, server, query, output='json', *args,**kwargs):
105+
def __init__(self, server, query, timeout, output='json', *args,**kwargs):
106106
super(_Select,self).__init__(server, query, *args,**kwargs)
107107
if output=='xml':
108108
self.headers['Accept'] = ','.join(self.acceptable_xml_responses)
109109
else:
110110
self.headers['Accept'] = ','.join(self.acceptable_json_responses)
111111

112+
if timeout is not None:
113+
self.headers['X-BIGDATA-MAX-QUERY-MILLIS'] = str(timeout)
114+
112115
def default_graph_uri(self):
113116
return 'default-graph-uri'
114117

@@ -176,7 +179,7 @@ def __init__(self, query_url, post_queries=False, post_directly=False):
176179
'application/sparql-results+xml',
177180
]
178181

179-
def query(self, sparql, *args, **kwargs):
182+
def query(self, sparql, timeout=None, *args, **kwargs):
180183
"""Executes a SPARQL query. The return type varies based on what the
181184
SPARQL store responds with:
182185
@@ -186,7 +189,7 @@ def query(self, sparql, *args, **kwargs):
186189
187190
:param sparql: The SPARQL to execute.
188191
:returns: The results of the query from the SPARQL store."""
189-
return _Select(self, sparql, *args, **kwargs).execute()
192+
return _Select(self, sparql, timeout, *args, **kwargs).execute()
190193

191194
def update(self, sparql, **kwargs):
192195
"""Executes a SPARQL update.

0 commit comments

Comments
 (0)