Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup media logcontexts #17561

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading