Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlapping task and coroutine can confuse yappi #58

Closed
asodeur opened this issue Aug 28, 2020 · 1 comment · Fixed by #94
Closed

Overlapping task and coroutine can confuse yappi #58

asodeur opened this issue Aug 28, 2020 · 1 comment · Fixed by #94
Assignees
Labels

Comments

@asodeur
Copy link

asodeur commented Aug 28, 2020

It seems yappi gets confused when a coroutine is scheduled as a task and awaited from the same function and the task returns first. If the task returns first the timings from the explicit await on the coroutine get lost (still contributes to the call count):

from asyncio import create_task, run, sleep
import yappi
yappi.set_clock_type('wall')

async def test(d=0):
    t = create_task(sleep(5+d))
    await sleep(5)
    await t

for d in [-2, 0, 2]:
    with yappi.run():
        run(test(d))
    print(f'#### d={d} (expect tsub ~ ttot ~ 2*5+d={2*5+d}):')  # but we get 5-d if d < 0
    yappi.get_func_stats(filter_callback=lambda x: yappi.func_matches(x, [sleep])).print_all()
    yappi.clear_stats()
@sumerc
Copy link
Owner

sumerc commented Nov 10, 2021

It has been a while since this task is opened. It turns out to be a simpler fix than I originally thought. Will be fixed in #94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants