Skip to content

Commit

Permalink
Merge pull request #1472 from matkoniecz/timeout
Browse files Browse the repository at this point in the history
stop timeouting after 45 seconds [ready for review]
  • Loading branch information
westnordost authored Jul 7, 2019
2 parents b3f447d + 5237d53 commit f5edef5
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,27 @@ public static OsmConnection osmConnection(OAuthConsumer consumer)
return new OsmMapDataFactory();
}

// see https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#timeout:
// default value is 180 seconds
// give additional 4 seconds to get and process refusal from Overpass
// or maybe a bit late response rather than trigger timeout exception
private static int OVERPASS_QUERY_TIMEOUT_IN_MILISECONDS = (180 + 4) * 1000;

@Provides public static OverpassMapDataDao overpassMapDataDao(
Provider<OverpassMapDataParser> parserProvider, SharedPreferences prefs)
{
Integer timeout = OVERPASS_QUERY_TIMEOUT_IN_MILISECONDS;
OsmConnection overpassConnection = new OsmConnection(
prefs.getString(Prefs.OVERPASS_URL, OVERPASS_API_WITH_ATTIC_DATA_URL), ApplicationConstants.USER_AGENT, null);
prefs.getString(Prefs.OVERPASS_URL, OVERPASS_API_WITH_ATTIC_DATA_URL), ApplicationConstants.USER_AGENT, null, timeout);
return new OverpassMapDataDao(overpassConnection, parserProvider);
}

@Provides public static OverpassOldMapDataDao overpassOldMapDataDao(
Provider<OverpassMapDataParser> parserProvider, String date)
{
Integer timeout = OVERPASS_QUERY_TIMEOUT_IN_MILISECONDS;
OsmConnection overpassConnection = new OsmConnection(
OVERPASS_API_WITH_ATTIC_DATA_URL, ApplicationConstants.USER_AGENT, null);
OVERPASS_API_WITH_ATTIC_DATA_URL, ApplicationConstants.USER_AGENT, null, timeout);
return new OverpassOldMapDataDao(overpassConnection, parserProvider, date);
}

Expand Down

0 comments on commit f5edef5

Please sign in to comment.