Python : SpaqrlWrapper, Timeout?

744 views Asked by At

I am new to python as well as new to the world of querying the semantic web. I am using SPARQLWrapper library to query dbpedia, I searched the library documentation but failed to find 'timeout' for a query fired to dbpedia from sparqlWrapper.

Anyone has any idea about the same.

4

There are 4 answers

1
JimiDini On BEST ANSWER

DBPedia uses Virtuoso server for it's endpoint and timeout is a virtuoso-specific option. SparqlWrapper doesn't currently support it.

Next version will feature better modularity and proper vendor-specific extensions might be implemented after that, but I guess you don't have time to wait.

Currently, the only way to add such parameter is to manually hardcode it into your local version of library

0
Karoo On

As of 2018, you can use SPARQLWrapper.setTimeout() to set the timeout for SPARQLWrapper requests.

3
cubexy On

I don't know if this is specifically an answer for your question, but I searched for it for ages and heres my solution for anyone else having trouble with Virtuoso specific timeouts on SPARQLWrapper:

Your can use this line of code to set a server-side timeout for your queries (not clientside like .setTimeout):

[your SPARQLWrapper entity].addExtraURITag("timeout","[your timeout in ms]")

In my case it looks like this:

s.addExtraURITag("timeout","10000")

This should give you 10 seconds of time before your query stops searching and returns results instead of just giving you a Timeout error.

Hope I could help anyone.

0
Kaschi14 On

As Karoo mentioned you can use SPARQLWrapper.setTimeout(timeout=(int)). If you want a timeout as a float, go to the Wrapper.py module and change self.timeout = int(timeout) to self.timeout = float(timeout) in the def setTimeout(self, timeout): function.