From 008d900f81584dc2b57acb9136f8a5837462ba9d Mon Sep 17 00:00:00 2001 From: Greg Hogan Date: Sat, 10 Feb 2018 09:31:56 -0600 Subject: [PATCH] fix restricting video upload to wifi --- selfdrive/loggerd/uploader.py | 37 ++++++++++++++++------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/selfdrive/loggerd/uploader.py b/selfdrive/loggerd/uploader.py index f04bb0d030..04e4dddbff 100755 --- a/selfdrive/loggerd/uploader.py +++ b/selfdrive/loggerd/uploader.py @@ -248,33 +248,30 @@ def uploader_fn(exit_event): uploader = Uploader(dongle_id, access_token, ROOT) + backoff = 0.1 while True: upload_video = (params.get("IsUploadVideoOverCellularEnabled") != "0") or is_on_wifi() - backoff = 0.1 - while True: - - if exit_event.is_set(): - return + if exit_event.is_set(): + return - d = uploader.next_file_to_upload(upload_video) - if d is None: - break + d = uploader.next_file_to_upload(upload_video) + if d is None: + time.sleep(5) + continue - key, fn, _ = d + key, fn, _ = d - cloudlog.info("to upload %r", d) - success = uploader.upload(key, fn) - if success: - backoff = 0.1 - else: - cloudlog.info("backoff %r", backoff) - time.sleep(backoff + random.uniform(0, backoff)) - backoff = min(backoff*2, 120) - cloudlog.info("upload done, success=%r", success) - - time.sleep(5) + cloudlog.info("to upload %r", d) + success = uploader.upload(key, fn) + if success: + backoff = 0.1 + else: + cloudlog.info("backoff %r", backoff) + time.sleep(backoff + random.uniform(0, backoff)) + backoff = min(backoff*2, 120) + cloudlog.info("upload done, success=%r", success) def main(gctx=None): uploader_fn(threading.Event())