diff options
author | Patrick Cloke <clokep@users.noreply.github.com> | 2021-03-09 07:41:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-09 07:41:32 -0500 |
commit | 7fdc6cefb3017f3c4bbe1d824e1de249ac29d219 (patch) | |
tree | eb7529b1b438b4cbff3c5ca6d30391f1bfd10a49 /synapse/logging | |
parent | Handle image transparency better when thumbnailing. (#9473) (diff) | |
download | synapse-7fdc6cefb3017f3c4bbe1d824e1de249ac29d219.tar.xz |
Fix additional type hints. (#9543)
Type hint fixes due to Twisted 21.2.0 adding type hints.
Diffstat (limited to 'synapse/logging')
-rw-r--r-- | synapse/logging/context.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/synapse/logging/context.py b/synapse/logging/context.py index 78e27bfb00..1a7ea4fa96 100644 --- a/synapse/logging/context.py +++ b/synapse/logging/context.py @@ -669,7 +669,7 @@ def preserve_fn(f): return g -def run_in_background(f, *args, **kwargs): +def run_in_background(f, *args, **kwargs) -> defer.Deferred: """Calls a function, ensuring that the current context is restored after return from the function, and that the sentinel context is set once the deferred returned by the function completes. @@ -697,8 +697,10 @@ def run_in_background(f, *args, **kwargs): if isinstance(res, types.CoroutineType): res = defer.ensureDeferred(res) + # At this point we should have a Deferred, if not then f was a synchronous + # function, wrap it in a Deferred for consistency. if not isinstance(res, defer.Deferred): - return res + return defer.succeed(res) if res.called and not res.paused: # The function should have maintained the logcontext, so we can |