From 9fe70570210642c40e6a1ab5f50c61b53509b940 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sat, 28 Mar 2020 16:42:54 -0700 Subject: [PATCH] Move refresher thread launcher into a function. --- frontends/ycdl_flask/ycdl_flask/ycdl_flask.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontends/ycdl_flask/ycdl_flask/ycdl_flask.py b/frontends/ycdl_flask/ycdl_flask/ycdl_flask.py index a98b72d..7b19950 100644 --- a/frontends/ycdl_flask/ycdl_flask/ycdl_flask.py +++ b/frontends/ycdl_flask/ycdl_flask/ycdl_flask.py @@ -271,16 +271,18 @@ def post_start_download(): #################################################################################################### #################################################################################################### -def refresher_thread(): +def refresher_thread(rate): while True: - time.sleep(60 * 60 * 6) + time.sleep(rate) print('Starting refresh job.') thread_kwargs = {'force': False, 'skip_failures': True} refresh_job = threading.Thread(target=ycdldb.refresh_all_channels, kwargs=thread_kwargs, daemon=True) refresh_job.start() -refresher = threading.Thread(target=refresher_thread, daemon=True) -refresher.start() +def start_refresher_thread(rate): + print(f'Starting refresher thread, once per {rate} seconds.') + refresher = threading.Thread(target=refresher_thread, args=[rate], daemon=True) + refresher.start() if __name__ == '__main__': pass