mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-14 11:57:44 +00:00
parent
9f9ec92526
commit
3e7eb45eb1
2 changed files with 10 additions and 2 deletions
1
changelog.d/17561.misc
Normal file
1
changelog.d/17561.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Speed up responding to media requests.
|
|
@ -50,7 +50,11 @@ from twisted.web.server import Request
|
||||||
from synapse.api.errors import Codes, cs_error
|
from synapse.api.errors import Codes, cs_error
|
||||||
from synapse.http.server import finish_request, respond_with_json
|
from synapse.http.server import finish_request, respond_with_json
|
||||||
from synapse.http.site import SynapseRequest
|
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.types import ISynapseReactor
|
||||||
from synapse.util import Clock
|
from synapse.util import Clock
|
||||||
from synapse.util.stringutils import is_ascii
|
from synapse.util.stringutils import is_ascii
|
||||||
|
@ -657,7 +661,7 @@ class ThreadedFileSender:
|
||||||
|
|
||||||
# We set the wakeup signal as we should start producing immediately.
|
# We set the wakeup signal as we should start producing immediately.
|
||||||
self.wakeup_event.set()
|
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)
|
return make_deferred_yieldable(self.deferred)
|
||||||
|
|
||||||
|
@ -672,6 +676,9 @@ class ThreadedFileSender:
|
||||||
def stopProducing(self) -> None:
|
def stopProducing(self) -> None:
|
||||||
"""interfaces.IPushProducer"""
|
"""interfaces.IPushProducer"""
|
||||||
|
|
||||||
|
# Unregister the consumer so we don't try and interact with it again.
|
||||||
|
self.consumer = None
|
||||||
|
|
||||||
# Terminate the thread loop.
|
# Terminate the thread loop.
|
||||||
self.wakeup_event.set()
|
self.wakeup_event.set()
|
||||||
self.stop_event.set()
|
self.stop_event.set()
|
||||||
|
|
Loading…
Reference in a new issue