mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:26:02 -04:00
Fix media repo breaking (#5593)
This commit is contained in:
parent
f8b52eb8c5
commit
0ee9076ffe
6 changed files with 60 additions and 26 deletions
|
@ -24,6 +24,7 @@ See doc/log_contexts.rst for details on how this works.
|
|||
|
||||
import logging
|
||||
import threading
|
||||
import types
|
||||
|
||||
from twisted.internet import defer, threads
|
||||
|
||||
|
@ -528,8 +529,9 @@ def run_in_background(f, *args, **kwargs):
|
|||
return from the function, and that the sentinel context is set once the
|
||||
deferred returned by the function completes.
|
||||
|
||||
Useful for wrapping functions that return a deferred which you don't yield
|
||||
on (for instance because you want to pass it to deferred.gatherResults()).
|
||||
Useful for wrapping functions that return a deferred or coroutine, which you don't
|
||||
yield or await on (for instance because you want to pass it to
|
||||
deferred.gatherResults()).
|
||||
|
||||
Note that if you completely discard the result, you should make sure that
|
||||
`f` doesn't raise any deferred exceptions, otherwise a scary-looking
|
||||
|
@ -544,6 +546,9 @@ def run_in_background(f, *args, **kwargs):
|
|||
# by synchronous exceptions, so let's turn them into Failures.
|
||||
return defer.fail()
|
||||
|
||||
if isinstance(res, types.CoroutineType):
|
||||
res = defer.ensureDeferred(res)
|
||||
|
||||
if not isinstance(res, defer.Deferred):
|
||||
return res
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue