From a36027bb326d7c90bde75edf88b6582abe43ad18 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 13 Aug 2024 14:30:54 +0100 Subject: [PATCH 1/2] Fixup media logcontexts --- synapse/media/_base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/synapse/media/_base.py b/synapse/media/_base.py index 21f334339bf..ad80098e9fb 100644 --- a/synapse/media/_base.py +++ b/synapse/media/_base.py @@ -50,7 +50,11 @@ from synapse.api.errors import Codes, cs_error from synapse.http.server import finish_request, respond_with_json from synapse.http.site import SynapseRequest -from synapse.logging.context import defer_to_thread, make_deferred_yieldable +from synapse.logging.context import ( + defer_to_thread, + make_deferred_yieldable, + run_in_background, +) from synapse.types import ISynapseReactor from synapse.util import Clock from synapse.util.stringutils import is_ascii @@ -657,7 +661,7 @@ def beginFileTransfer( # We set the wakeup signal as we should start producing immediately. self.wakeup_event.set() - defer_to_thread(self.reactor, self._on_thread_read_loop) + run_in_background(defer_to_thread, self.reactor, self._on_thread_read_loop) return make_deferred_yieldable(self.deferred) @@ -672,6 +676,9 @@ def pauseProducing(self) -> None: def stopProducing(self) -> None: """interfaces.IPushProducer""" + # Unregister the consumer so we don't try and interact with it again. + self.consumer = None + # Terminate the thread loop. self.wakeup_event.set() self.stop_event.set() From b8ba98659a8a3967b5937358effc54f5bb024a35 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 13 Aug 2024 14:31:46 +0100 Subject: [PATCH 2/2] Newsfile --- changelog.d/17561.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/17561.misc diff --git a/changelog.d/17561.misc b/changelog.d/17561.misc new file mode 100644 index 00000000000..cfa8089a810 --- /dev/null +++ b/changelog.d/17561.misc @@ -0,0 +1 @@ +Speed up responding to media requests.