From cd17dc3d7e26293d7b13ca48864bd60e93b8da61 Mon Sep 17 00:00:00 2001 From: Adam Kramer Date: Sun, 9 Mar 2014 21:32:36 -0700 Subject: [PATCH] When modifications are necessary, sync immediately rather than waiting for the sleep interval. --- nextaction.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nextaction.py b/nextaction.py index 5d3e030..4c1bd09 100755 --- a/nextaction.py +++ b/nextaction.py @@ -315,11 +315,12 @@ def main(): logging.debug("Got initial data: %s", json_data) a = TodoistData(json_data) while True: - time.sleep(5) - logging.info("** Beginning sync") - logging.info("* Generating modifications") mods = a.GetProjectMods() - logging.info("* Finished generating modifications") + if len(mods) == 0: + time.sleep(5) + else: + logging.info("* Modifications necessary - skipping sleep cycle.") + logging.info("** Beginning sync") sync_state = a.GetSyncState() changed_data = DoSyncAndGetUpdated(mods, sync_state).read() logging.debug("Got sync data %s", changed_data)