From 3db98d186f276d9fab58cd25f71a7e69b985a7c5 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Sat, 15 Nov 2014 19:56:37 +0000 Subject: [PATCH] Add sync delay, to tune the speed of hits on the Todoist API. --- app.json | 5 +++++ nextaction.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app.json b/app.json index 5ddd379..f5ef281 100644 --- a/app.json +++ b/app.json @@ -12,5 +12,10 @@ "description": "The Todoist label to use for next actions.", "value": "next_action", "required": false + }, + "TODOIST_SYNC_DELAY": { + "description": "The number of seconds to wait between syncs.", + "value": "5", + "required": false } } \ No newline at end of file diff --git a/nextaction.py b/nextaction.py index d602359..3f5001f 100755 --- a/nextaction.py +++ b/nextaction.py @@ -13,6 +13,7 @@ import sys API_TOKEN = os.environ.get('TODOIST_API_KEY', None) NEXT_ACTION_LABEL = os.environ.get('TODOIST_NEXT_ACTION_LABEL', 'next_action') +SYNC_DELAY = int(os.environ.get('TODOIST_SYNC_DELAY', '5')) TODOIST_VERSION = '5.3' @@ -393,7 +394,7 @@ def main(): logging.info("*** Data built") mods = singleton.GetProjectMods() if len(mods) == 0: - time.sleep(5) + time.sleep(SYNC_DELAY) else: logging.info("* Modifications necessary - skipping sleep cycle.") logging.info("** Beginning sync")