Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NLMaps Tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Simon Will
NLMaps Tools
Commits
04307ea2
Commit
04307ea2
authored
4 years ago
by
Simon Will
Browse files
Options
Downloads
Patches
Plain Diff
Try a second Overpass query after API failure
parent
a57dd2ff
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nlmaps_tools/overpass_round_robin.py
+17
-3
17 additions, 3 deletions
nlmaps_tools/overpass_round_robin.py
with
17 additions
and
3 deletions
nlmaps_tools/overpass_round_robin.py
+
17
−
3
View file @
04307ea2
import
random
import
logging
import
traceback
from
OSMPythonTools.overpass
import
Overpass
...
...
@@ -31,6 +32,19 @@ class OverpassRoundRobin:
return
instance
def
query
(
self
,
*
args
,
**
kwargs
):
overpass
=
self
.
_get_instance
()
logging
.
info
(
'
Using Overpass at {}
'
.
format
(
overpass
.
_endpoint
))
return
overpass
.
query
(
*
args
,
**
kwargs
)
tries
=
kwargs
.
pop
(
'
tries
'
,
2
)
while
tries
>
0
:
tries
-=
1
overpass
=
self
.
_get_instance
()
logging
.
info
(
'
Using Overpass at {}
'
.
format
(
overpass
.
_endpoint
))
try
:
result
=
overpass
.
query
(
*
args
,
**
kwargs
)
return
result
except
Exception
as
e
:
logging
.
error
(
'
Error when querying {}:
'
.
format
(
overpass
.
_endpoint
))
logging
.
error
(
traceback
.
format_exc
())
if
tries
>
0
:
logging
.
info
(
'
Trying again.
'
)
else
:
raise
e
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment