3

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.

Ankit Solanki
  • 670
  • 2
  • 9
  • 23

4 Answers4

2

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

Karoo
  • 542
  • 6
  • 19
1

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.

Kaschi14
  • 116
  • 5
1

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.

cubexy
  • 119
  • 1
  • 10
  • 1
    Thanks for this but even after setting the timeout to 0 i.e. to run completely, sometimes I get a partial response, any ideas why? [dbpedia-partial-result](https://www.dbpedia.org/resources/sparql/#:~:text=Partial%20Results%20for%20Timed%2DOut%20Queries%20(Anytime%20Queries)) [timeout 0 settings](http://docs.openlinksw.com/virtuoso/anytimequeries/#:~:text=Setting%20the%20timeout%20to%200%20returns%20to%20the%20default%20state%20of%20having%20no%20limit%20on%20query%20run%20time%20and%20always%20returning%20complete%20results.) – Shubham Srivastava Jun 16 '22 at 06:34
  • @ShubhamSrivastava Sounds like there is a default timeout that is used! – cubexy Aug 30 '22 at 09:05
  • 1
    good guess. It looks like this specific to DBpedia, they have a MaxQueryExecutionTime of 120sec, so even if we set it to 0 in code, they are maintaining a default settings. – Shubham Srivastava Aug 30 '22 at 11:06
0

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

JimiDini
  • 2,039
  • 12
  • 19
  • True, I guess the only option now is to manually code the timeout. BTW thanks for writing back, I felt that wasn't able to locate the timeout in the library and was searching for it all the while. This marks end to my search ;) – Ankit Solanki Dec 06 '13 at 15:09