Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposed the timeout of SPARQLWrapper #531

Merged
merged 3 commits into from
Nov 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions rdflib/plugins/stores/sparqlstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ def __init__(self,
self.sparql11 = sparql11
self.context_aware = context_aware
self.graph_aware = context_aware
self._timeout = None

# Database Management Methods
def create(self, configuration):
Expand Down Expand Up @@ -322,6 +323,7 @@ def query(self, query,
self.resetQuery()
if self._is_contextual(queryGraph):
self.addParameter("default-graph-uri", queryGraph)
self.timeout = self._timeout
self.setQuery(query)

return Result.parse(SPARQLWrapper.query(self).response)
Expand Down Expand Up @@ -409,6 +411,7 @@ def triples(self, (s, p, o), context=None):
self.resetQuery()
if self._is_contextual(context):
self.addParameter("default-graph-uri", context.identifier)
self.timeout = self._timeout
self.setQuery(query)

doc = ElementTree.parse(SPARQLWrapper.query(self).response)
Expand Down Expand Up @@ -740,10 +743,14 @@ def remove(self, spo, context):
if self.autocommit:
self.commit()

def setTimeout(self, timeout):
self._timeout = int(timeout)

def _do_update(self, update):
self.resetQuery()
self.setQuery(update)
self.setMethod(POST)
self.timeout = self._timeout
self.setRequestMethod(URLENCODED if self.postAsEncoded else POSTDIRECTLY)

result = SPARQLWrapper.query(self)
Expand Down