mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-22 01:25:44 +03:00
Track run_in_background
This commit is contained in:
parent
032c0d9970
commit
7a0d090adc
1 changed files with 4 additions and 2 deletions
|
@ -821,13 +821,15 @@ def run_in_background(
|
|||
d: "defer.Deferred[R]"
|
||||
if isinstance(res, typing.Coroutine):
|
||||
# Wrap the coroutine in a `Deferred`.
|
||||
d = defer.ensureDeferred(res)
|
||||
d = defer.ensureDeferred(measure_coroutine(current.name, res))
|
||||
elif isinstance(res, defer.Deferred):
|
||||
d = res
|
||||
elif isinstance(res, Awaitable):
|
||||
# `res` is probably some kind of completed awaitable, such as a `DoneAwaitable`
|
||||
# or `Future` from `make_awaitable`.
|
||||
d = defer.ensureDeferred(_unwrap_awaitable(res))
|
||||
d = defer.ensureDeferred(
|
||||
measure_coroutine(current.name, _unwrap_awaitable(res))
|
||||
)
|
||||
else:
|
||||
# `res` is a plain value. Wrap it in a `Deferred`.
|
||||
d = defer.succeed(res)
|
||||
|
|
Loading…
Reference in a new issue