mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-14 08:45:29 -04:00
Wrap a number of things that run in the background
This will reduce the number of "Starting db connection from sentinel context" warnings, and will help with our metrics.
This commit is contained in:
parent
1e5dbdcbb1
commit
371da42ae4
9 changed files with 63 additions and 22 deletions
|
@ -41,6 +41,7 @@ from synapse.http.server import (
|
|||
wrap_json_request_handler,
|
||||
)
|
||||
from synapse.http.servlet import parse_integer, parse_string
|
||||
from synapse.metrics.background_process_metrics import run_as_background_process
|
||||
from synapse.util.async import ObservableDeferred
|
||||
from synapse.util.caches.expiringcache import ExpiringCache
|
||||
from synapse.util.logcontext import make_deferred_yieldable, run_in_background
|
||||
|
@ -81,7 +82,7 @@ class PreviewUrlResource(Resource):
|
|||
self._cache.start()
|
||||
|
||||
self._cleaner_loop = self.clock.looping_call(
|
||||
self._expire_url_cache_data, 10 * 1000
|
||||
self._start_expire_url_cache_data, 10 * 1000,
|
||||
)
|
||||
|
||||
def render_OPTIONS(self, request):
|
||||
|
@ -371,6 +372,11 @@ class PreviewUrlResource(Resource):
|
|||
"etag": headers["ETag"][0] if "ETag" in headers else None,
|
||||
})
|
||||
|
||||
def _start_expire_url_cache_data(self):
|
||||
run_as_background_process(
|
||||
"expire_url_cache_data", self._expire_url_cache_data,
|
||||
)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def _expire_url_cache_data(self):
|
||||
"""Clean up expired url cache content, media and thumbnails.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue