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

[BUG] track progressbar is not working correctly with asyncio after rich 4.1.0 #189

Closed
Niraj-Kamdar opened this issue Jul 29, 2020 · 2 comments

Comments

@Niraj-Kamdar
Copy link

Describe the bug
track stops iterating after producing one value while running asynchronously.

To Reproduce
Following code is just to simulate bug. I am using rich progress bar to track progress of asynchronous downloading tasks.

async def sleeper(val):
    await asyncio.sleep(1)
    return val


async def scheduler():
    tasks = [sleeper(i) for i in range(10)]
    total_tasks = len(tasks)
    for task in track(
            asyncio.as_completed(tasks),
            description="Processing...",
            total=total_tasks,
    ):
        await task


def get_event_loop():
    try:
        loop = asyncio.get_event_loop()
    except RuntimeError:
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
    if sys.platform.startswith("win"):
        if isinstance(loop, asyncio.SelectorEventLoop):
            loop = asyncio.ProactorEventLoop()
            asyncio.set_event_loop(loop)
    return loop


def run_coroutine(coro):
    loop = get_event_loop()
    aws = asyncio.ensure_future(coro)
    result = loop.run_until_complete(aws)
    return result


if __name__ == "__main__":
    run_coroutine(scheduler())

Platform
What platform (Win/Linux/Mac) are you running on?
I have tried on both Linux and Windows and both are producing same bug.

What terminal software are you using?
bash terminal on linux and powershell on windows.

Which version of Rich?
rich>=4.1.0 produces this bug. Works fine in rich<=4.0.0

@willmcgugan
Copy link
Collaborator

Try v4.2.1

@Niraj-Kamdar
Copy link
Author

Thanks! It's working fine now.

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

No branches or pull requests

2 participants