From 6216f7872c72c058fc3c4c5daac69481126086a6 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Mon, 6 Apr 2020 20:12:34 -0700 Subject: [PATCH] glib: Allow scheduling non-repeating tasks in separate threads Signed-off-by: Sunil Mohan Adapa --- plinth/glib.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plinth/glib.py b/plinth/glib.py index dc535defe..85a48c872 100644 --- a/plinth/glib.py +++ b/plinth/glib.py @@ -47,8 +47,9 @@ def _run(): logger.info('Glib main loop thread exited.') -def schedule(interval, method, data=None, in_thread=True): +def schedule(interval, method, data=None, in_thread=True, repeat=True): """Schedule a recurring call to a method with fixed interval.""" + def _runner(): """Run the target method and log and exceptions.""" try: @@ -64,6 +65,6 @@ def schedule(interval, method, data=None, in_thread=True): thread = threading.Thread(target=_runner) thread.start() - return True + return repeat glib.timeout_add(int(interval * 1000), _run_bare_or_thread, None)