From a6c98fec3158e1a51f8fd9bcf59141d80d2fdf45 Mon Sep 17 00:00:00 2001 From: Sean Quah Date: Tue, 7 Dec 2021 10:55:52 +0000 Subject: [PATCH 1/2] Fix `ModuleApi.looping_background_call` for non-async functions After #10847, `looping_background_call` would print an error in the logs every time a non-async function was called. Since the error would be caught and ignored immediately, there were no other side effects. --- changelog.d/11523.bugfix | 1 + synapse/module_api/__init__.py | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 changelog.d/11523.bugfix diff --git a/changelog.d/11523.bugfix b/changelog.d/11523.bugfix new file mode 100644 index 000000000000..6e1e4bd44c3c --- /dev/null +++ b/changelog.d/11523.bugfix @@ -0,0 +1 @@ +Fix a regression in Synapse 1.48.0 where the module API's `looping_background_call` method would spam errors to the logs when given a non-async function. diff --git a/synapse/module_api/__init__.py b/synapse/module_api/__init__.py index 6bfb4b8d1be1..662e60bc3394 100644 --- a/synapse/module_api/__init__.py +++ b/synapse/module_api/__init__.py @@ -108,6 +108,7 @@ create_requester, ) from synapse.util import Clock +from synapse.util.async_helpers import maybe_awaitable from synapse.util.caches.descriptors import cached if TYPE_CHECKING: @@ -1014,9 +1015,7 @@ def looping_background_call( run_as_background_process, msec, desc, - f, - *args, - **kwargs, + lambda: maybe_awaitable(f(*args, **kwargs)), ) else: logger.warning( From c5b6d2d180e2e9d2e8ddf05d90a9a080b1b54502 Mon Sep 17 00:00:00 2001 From: Sean Quah Date: Tue, 7 Dec 2021 11:05:08 +0000 Subject: [PATCH 2/2] Fix newsfile --- changelog.d/{11523.bugfix => 11524.bugfix} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelog.d/{11523.bugfix => 11524.bugfix} (100%) diff --git a/changelog.d/11523.bugfix b/changelog.d/11524.bugfix similarity index 100% rename from changelog.d/11523.bugfix rename to changelog.d/11524.bugfix