From 67108ec617a2643c9040fd0171d21f198c8ecc31 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 26 Nov 2020 18:19:10 -0800 Subject: [PATCH] Add backoff to do_tasks. --- do_tasks.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/do_tasks.py b/do_tasks.py index 2f85255..17d4109 100644 --- a/do_tasks.py +++ b/do_tasks.py @@ -7,6 +7,9 @@ import send2trash import sys import time +from voussoirkit import backoff + +bo = backoff.Linear(m=1, b=5, max=300) def get_task_files(): return [f for f in os.listdir() if (os.path.isfile(f) and f.endswith('.task'))] @@ -27,9 +30,11 @@ def do_tasks_forever(): while True: print(time.strftime('%H:%M:%S'), 'Looking for tasks.') task_files = get_task_files() + if task_files: + bo.reset() do_tasks(task_files) try: - time.sleep(10) + time.sleep(bo.next()) except KeyboardInterrupt: break