summary refs log tree commit diff
path: root/synapse/module_api/__init__.py
diff options
context:
space:
mode:
authorAndrew Morgan <andrew@amorgan.xyz>2021-08-18 14:23:52 +0100
committerAndrew Morgan <andrew@amorgan.xyz>2021-08-18 14:23:52 +0100
commit2f4fe530a1cc12d6b7aec746bac55d40961616ac (patch)
treeaf56fac4739b696489f8e15617cbd81115b1a6cf /synapse/module_api/__init__.py
parentMerge branch 'release-v1.41' into matrix-org-hotfixes (diff)
parentMount /_synapse/admin/v1/users/{userId}/media admin API on media workers only... (diff)
downloadsynapse-2f4fe530a1cc12d6b7aec746bac55d40961616ac.tar.xz
Merge branch 'release-v1.41' of github.com:matrix-org/synapse into matrix-org-hotfixes
Diffstat (limited to 'synapse/module_api/__init__.py')
-rw-r--r--synapse/module_api/__init__.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py

index 2f99d31c42..2d2ed229e2 100644 --- a/synapse/module_api/__init__.py +++ b/synapse/module_api/__init__.py
@@ -604,10 +604,15 @@ class ModuleApi: msec: float, *args, desc: Optional[str] = None, + run_on_all_instances: bool = False, **kwargs, ): """Wraps a function as a background process and calls it repeatedly. + NOTE: Will only run on the instance that is configured to run + background processes (which is the main process by default), unless + `run_on_all_workers` is set. + Waits `msec` initially before calling `f` for the first time. Args: @@ -618,12 +623,14 @@ class ModuleApi: msec: How long to wait between calls in milliseconds. *args: Positional arguments to pass to function. desc: The background task's description. Default to the function's name. + run_on_all_instances: Whether to run this on all instances, rather + than just the instance configured to run background tasks. **kwargs: Key arguments to pass to function. """ if desc is None: desc = f.__name__ - if self._hs.config.run_background_tasks: + if self._hs.config.run_background_tasks or run_on_all_instances: self._clock.looping_call( run_as_background_process, msec,