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(
604
604
msec : float ,
605
605
* args ,
606
606
desc : Optional [str ] = None ,
607
+ run_on_all_instances : bool = False ,
607
608
** kwargs ,
608
609
):
609
610
"""Wraps a function as a background process and calls it repeatedly.
610
611
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
+
611
616
Waits `msec` initially before calling `f` for the first time.
612
617
613
618
Args:
@@ -618,12 +623,14 @@ def looping_background_call(
618
623
msec: How long to wait between calls in milliseconds.
619
624
*args: Positional arguments to pass to function.
620
625
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.
621
628
**kwargs: Key arguments to pass to function.
622
629
"""
623
630
if desc is None :
624
631
desc = f .__name__
625
632
626
- if self ._hs .config .run_background_tasks :
633
+ if self ._hs .config .run_background_tasks or run_on_all_instances :
627
634
self ._clock .looping_call (
628
635
run_as_background_process ,
629
636
msec ,
You can’t perform that action at this time.
0 commit comments