Skip to content

Commit

Permalink
Merge pull request #1336 from matkoniecz/504
Browse files Browse the repository at this point in the history
add documentation, handle 504
  • Loading branch information
rmarianski authored Jul 27, 2017
2 parents 96bf0bf + 210227d commit 884c67c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions integration-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,24 @@ def query_result(self, query):
r = requests.get("http://%s/api/interpreter" % OVERPASS_SERVER,
params=dict(data=query))
if r.status_code == 200:
# "200 OK is sent when the query has been successfully answered.
# The payload of the response is the result data."
# quote from http://overpass-api.de/command_line.html
# so response is usable
break
if r.status_code != 429:

if r.status_code not in (429, 504):
# "429 Too Many Requests is sent if you pass multiple queries from one IP"
# regularly happens with multiple sequential querries
# "504 Gateway Timeout is sent if the server has already so much
# load that the request cannot be executed. In most cases,
# it is best to try again later"
# quotes from http://overpass-api.de/command_line.html

# in cases of 429 and 504 waiting and retrying is typically enough to get an expected response
break
print "429 code returned instead of overpass response - request will be repeated after %d seconds" % wait_time_in_s

print "%d code returned instead of overpass response - request will be repeated after %d seconds" % (r.status_code, wait_time_in_s)
time.sleep(wait_time_in_s)

if r.status_code != 200:
Expand Down

0 comments on commit 884c67c

Please sign in to comment.