mvexel / overpass-api-python-wrapper

Python bindings for the OpenStreetMap Overpass API
Apache License 2.0
367 stars 90 forks source link

Handle server runtime error from overpass API #35

Closed atlefren closed 8 years ago

atlefren commented 8 years ago

I used this project to send the following query:

area["ISO3166-1"="US"]->.search;
(
  node[industrial=brewery](area.search);
  node[microbrewery=yes](area.search);
  node[craft=brewery](area.search);
  way[industrial=brewery](area.search);
  way[microbrewery=yes](area.search);
  way[craft=brewery](area.search);
  relation[industrial=brewery](area.search);
  relation[microbrewery=yes](area.search);
  relation[craft=brewery](area.search);
);
out geom;

But after a while I got an empty response. After digging a bit more I found that the overpass API returned a response akin to the one described here: https://github.com/drolbr/Overpass-API/issues/104

Strangely enough the response had a 200 OK status code, so this lib continued to return the empty elements array, leaving me none the wiser.

This PR tries to remedy this, by raising a ServerRuntimeError exception when this happens.

tbolender commented 8 years ago

Do you always receive an empty response or only sometimes? Which Python version are you using? When I execute the request (2.7 and 3.4) I receive a TimeoutError after a while.

atlefren commented 8 years ago

I set the timeout parameter quite high (600), using Python 2.7.6 (Ubuntu trusty)

I haven't tried all that many times, but it happened tree or four times in a row, then I started investigating and was able to make this fix (using a couple more requests), so approx 5-6 times in a row at least. Strange if you are not able to reproduce it.

tbolender commented 8 years ago

The timeout value was the key, with 600 I receive an empty response. Thank you for the pull request!

atlefren commented 8 years ago

Great, thanks for a great library!