This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 1+ Add option to allow modules to run periodic tasks on all instances, rather than just the one configured to run background tasks.
Original file line number Diff line number Diff line change @@ -604,10 +604,15 @@ def looping_background_call(
604604 msec : float ,
605605 * args ,
606606 desc : Optional [str ] = None ,
607+ run_on_all_instances : bool = False ,
607608 ** kwargs ,
608609 ):
609610 """Wraps a function as a background process and calls it repeatedly.
610611
612+ NOTE: Will only run on the instance that is configured to run
613+ background processes (which is the main process by default), unless
614+ `run_on_all_workers` is set.
615+
611616 Waits `msec` initially before calling `f` for the first time.
612617
613618 Args:
@@ -618,12 +623,14 @@ def looping_background_call(
618623 msec: How long to wait between calls in milliseconds.
619624 *args: Positional arguments to pass to function.
620625 desc: The background task's description. Default to the function's name.
626+ run_on_all_instances: Whether to run this on all instances, rather
627+ than just the instance configured to run background tasks.
621628 **kwargs: Key arguments to pass to function.
622629 """
623630 if desc is None :
624631 desc = f .__name__
625632
626- if self ._hs .config .run_background_tasks :
633+ if self ._hs .config .run_background_tasks or run_on_all_instances :
627634 self ._clock .looping_call (
628635 run_as_background_process ,
629636 msec ,
You can’t perform that action at this time.
0 commit comments