Make the GTFS-R client resilient to network errors.
This commit is contained in:
parent
36749669b4
commit
35d0261682
|
|
@ -253,6 +253,7 @@ class GTFSClient():
|
|||
|
||||
def __poll_gtfsr_deltas(self) -> list[map, set]:
|
||||
|
||||
try:
|
||||
# Poll GTFS-R API
|
||||
if self.gtfs_r_api_key != "":
|
||||
headers = {"x-api-key": self.gtfs_r_api_key}
|
||||
|
|
@ -330,6 +331,9 @@ class GTFSClient():
|
|||
raise(x)
|
||||
|
||||
return deltas, canceled_trips, added_stops
|
||||
except Exception as e:
|
||||
print("Polling for GTFS-R failed:", str(e))
|
||||
return ({}, [], [])
|
||||
|
||||
|
||||
def get_next_n_buses(self, num_entries: int) -> pd.core.frame.DataFrame:
|
||||
|
|
@ -348,7 +352,6 @@ class GTFSClient():
|
|||
"""
|
||||
Create and enqueue the refreshed stop data
|
||||
"""
|
||||
print("Refresh")
|
||||
# Retrieve the GTFS-R deltas
|
||||
deltas, canceled_trips, added_stops = self.__poll_gtfsr_deltas()
|
||||
if len(deltas) > 0 or len(canceled_trips) > 0 or len(added_stops) > 0:
|
||||
|
|
|
|||
Loading…
Reference in New Issue