Preserve log context over when deferring to thread pool in media repo

This commit is contained in:
Erik Johnston 2016-02-03 16:17:18 +00:00
parent c8e4d5de7f
commit 33c71c3a4b
1 changed files with 7 additions and 4 deletions

View File

@ -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)