When modifications are necessary, sync immediately rather than waiting for the sleep interval.

master
Adam Kramer 2014-03-09 21:32:36 -07:00
parent 7021f38c35
commit cd17dc3d7e
1 changed files with 5 additions and 4 deletions

View File

@ -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)