glib: Change API for repeating an in-thread scheduled task

Previously, in glib.schedule(), when in_thread is set to True, it is expected
that the task method return whether it wants to be repeated (True) or
not (False). However, this was not documented and different from the behavior of
the separate-thread task (passed as argument repeat=). To simply and improve
consistency, use the repeat= argument instead of return value from the method.

This fixes issue with daily diagnostics not running for the second time.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa 2024-01-23 11:40:57 -08:00
parent d7907e0ef3
commit c96c97166f
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -65,7 +65,8 @@ def schedule(interval, method, data=None, in_thread=True, repeat=True,
def _run_bare_or_thread(_user_data):
"""Run the target method in thread or directly (if async)."""
if not in_thread:
return _runner()
_runner()
return repeat
thread = threading.Thread(target=_runner)
thread.start()