mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-04 16:54:56 -04:00
Fix additional type hints. (#9543)
Type hint fixes due to Twisted 21.2.0 adding type hints.
This commit is contained in:
parent
075c16b410
commit
7fdc6cefb3
9 changed files with 32 additions and 18 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue