diff options
author | Erik Johnston <erik@matrix.org> | 2016-02-03 16:17:18 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-02-03 16:17:18 +0000 |
commit | 33c71c3a4b06852285d8e446cbe2f57293ae0975 (patch) | |
tree | 5810b3e5b54e07ebce2d4bfe586119eb77e0758c /synapse | |
parent | Merge pull request #555 from matrix-org/erikj/logcontext (diff) | |
download | synapse-33c71c3a4b06852285d8e446cbe2f57293ae0975.tar.xz |
Preserve log context over when deferring to thread pool in media repo
Diffstat (limited to 'synapse')
-rw-r--r-- | synapse/rest/media/v1/base_resource.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/synapse/rest/media/v1/base_resource.py b/synapse/rest/media/v1/base_resource.py index bdc65f0198..58d56ec7a4 100644 --- a/synapse/rest/media/v1/base_resource.py +++ b/synapse/rest/media/v1/base_resource.py @@ -28,6 +28,7 @@ from twisted.protocols.basic import FileSender from synapse.util.async import ObservableDeferred from synapse.util.stringutils import is_ascii +from synapse.util.logcontext import preserve_context_over_fn import os @@ -276,7 +277,8 @@ class BaseMediaResource(Resource): ) self._makedirs(t_path) - t_len = yield threads.deferToThread( + t_len = yield preserve_context_over_fn( + threads.deferToThread, self._generate_thumbnail, input_path, t_path, t_width, t_height, t_method, t_type ) @@ -298,7 +300,8 @@ class BaseMediaResource(Resource): ) self._makedirs(t_path) - t_len = yield threads.deferToThread( + t_len = yield preserve_context_over_fn( + threads.deferToThread, self._generate_thumbnail, input_path, t_path, t_width, t_height, t_method, t_type ) @@ -372,7 +375,7 @@ class BaseMediaResource(Resource): media_id, t_width, t_height, t_type, t_method, t_len )) - yield threads.deferToThread(generate_thumbnails) + yield preserve_context_over_fn(threads.deferToThread, generate_thumbnails) for l in local_thumbnails: yield self.store.store_local_thumbnail(*l) @@ -445,7 +448,7 @@ class BaseMediaResource(Resource): t_width, t_height, t_type, t_method, t_len ]) - yield threads.deferToThread(generate_thumbnails) + yield preserve_context_over_fn(threads.deferToThread, generate_thumbnails) for r in remote_thumbnails: yield self.store.store_remote_media_thumbnail(*r) |