Skip to content

Commit

Permalink
Fixup media logcontexts (#17561)
Browse files Browse the repository at this point in the history
Regression from #17558
  • Loading branch information
erikjohnston authored Aug 13, 2024
1 parent 9f9ec92 commit 3e7eb45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions changelog.d/17561.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Speed up responding to media requests.
11 changes: 9 additions & 2 deletions synapse/media/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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()
Expand Down

0 comments on commit 3e7eb45

Please sign in to comment.