Skip to content
This repository has been archived by the owner on May 9, 2023. It is now read-only.

Commit

Permalink
sensible output for who waits on whom
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaqq committed Aug 28, 2019
1 parent e390beb commit 606a965
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions test/test_scenario.py
Expand Up @@ -34,16 +34,42 @@ async def b_branch(f):
await f


def name(t):
try:
# Python3.8
return t.get_name()
except AttributeError:
return f"Task-{id(t)}"


async def test():
import sys

# import awaitwhat
await asyncio.sleep(0.1)
print("### Python native")
for t in asyncio.Task.all_tasks():
for t in asyncio.all_tasks():
print(name(t))
asyncio.base_tasks._task_print_stack(t, None, sys.stdout)
print()

for t in asyncio.all_tasks():
waiter = t._fut_waiter
"""
# FIXME waiter is not a Task, it's a:
* _asyncio.Future
* asyncio.tasks._GatheringFuture
* ...
* None
"""
try:
waiter = ", ".join(map(name, waiter._children))
except AttributeError:
pass
print(f"{name(t)} -> {waiter}")

# Extended stack
# import awaitwhat

for f in FUTURES:
f.set_result(None)

Expand Down

0 comments on commit 606a965

Please sign in to comment.