Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Trace functions which return Awaitable #15650

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
No need for extra async function layer when ensureDeferred works wi…
…th and `Awaitable` coroutine or `Deferred`

See #15650 (comment)
  • Loading branch information
MadLittleMods committed Jun 1, 2023
commit 9c96b06cd2656ca46d17de17571591f08a2a83ca
9 changes: 2 additions & 7 deletions tests/logging/test_opentracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,18 +290,13 @@ def test_trace_decorator_awaitable_return(self) -> None:
async def fixture_async_func() -> str:
return "foo"

# The actual kind of function we want to test that returns an awaitable
# The actual kind of function we want to test that returns an awaitable coroutine
@trace_with_opname("fixture_awaitable_return_func", tracer=self._tracer)
@tag_args
def fixture_awaitable_return_func() -> Awaitable[str]:
return fixture_async_func()

# Something we can run with `defer.ensureDeferred(runner())` and pump the
# whole async tasks through to completion.
async def runner() -> str:
return await fixture_awaitable_return_func()

d1 = defer.ensureDeferred(runner())
d1 = defer.ensureDeferred(fixture_awaitable_return_func())

# let the tasks complete
reactor.pump((2,) * 8)
Expand Down