diff options
author | Richard van der Hoff <1389908+richvdh@users.noreply.github.com> | 2018-10-23 13:12:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-23 13:12:32 +0100 |
commit | 5c445114d356c9c23b99f0a2c4246be983a38b69 (patch) | |
tree | 81a82e1a752e1e8fa9abeb7ad7cf72841c75adda /synapse/rest/media/v1/storage_provider.py | |
parent | Merge pull request #3698 from spantaleev/add-matrix-docker-ansible-deploy (diff) | |
download | synapse-5c445114d356c9c23b99f0a2c4246be983a38b69.tar.xz |
Correctly account for cpu usage by background threads (#4074)
Wrap calls to deferToThread() in a thing which uses a child logcontext to attribute CPU usage to the right request. While we're in the area, remove the logcontext_tracer stuff, which is never used, and afaik doesn't work. Fixes #4064
Diffstat (limited to 'synapse/rest/media/v1/storage_provider.py')
-rw-r--r-- | synapse/rest/media/v1/storage_provider.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/rest/media/v1/storage_provider.py b/synapse/rest/media/v1/storage_provider.py index 7b9f8b4d79..5aa03031f6 100644 --- a/synapse/rest/media/v1/storage_provider.py +++ b/synapse/rest/media/v1/storage_provider.py @@ -17,9 +17,10 @@ import logging import os import shutil -from twisted.internet import defer, threads +from twisted.internet import defer from synapse.config._base import Config +from synapse.util import logcontext from synapse.util.logcontext import run_in_background from .media_storage import FileResponder @@ -120,7 +121,8 @@ class FileStorageProviderBackend(StorageProvider): if not os.path.exists(dirname): os.makedirs(dirname) - return threads.deferToThread( + return logcontext.defer_to_thread( + self.hs.get_reactor(), shutil.copyfile, primary_fname, backup_fname, ) |