diff --git a/nextbus.py b/nextbus.py index 2e88f85d05a926254d299319d8169950593d7e2b..4ca67cbb17ef13c33ec2959587de7d09268df51a 100644 --- a/nextbus.py +++ b/nextbus.py @@ -366,13 +366,15 @@ class Nextbus(): return predictions @classmethod - def get_vehicle_locations(cls, agency_tags, truncate=True): + def get_vehicle_locations(cls, agency_tags, truncate=True, max_wait=10): """ Get vehicle GPS locations """ if not agency_tags: return [] - with Lock("agencies", shared=True), Lock("routes", shared=True), Lock("vehicle_locations"): + with Lock("agencies", shared=True, timeout=max_wait),\ + Lock("routes", shared=True, timeout=max_wait),\ + Lock("vehicle_locations", timeout=max_wait): db.session.begin() routes = db.session.query(Route).join(Agency)\ .options(joinedload('directions'))\