From d24c0fba613219e0c2efae5dcc91ccbdab5089df Mon Sep 17 00:00:00 2001 From: Raphael Roberts Date: Wed, 24 Apr 2019 14:09:47 -0500 Subject: [PATCH] fixed spam when network connection is dropped --- main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index c18f440..61ae28d 100755 --- a/main.py +++ b/main.py @@ -188,12 +188,13 @@ def main(args): timeout = args.periodic data = ctabus.get_times(stop_id, timeout=timeout) e = time.perf_counter() - s - if e < args.periodic: - time.sleep(args.periodic-e) except KeyboardInterrupt: _done = True except (urllib.error.URLError, socket.timeout): + e = time.perf_counter() - s print("Error fetching times") + if e < args.periodic: + time.sleep(args.periodic-e) else: show(data, args.route)