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] Progress bar doesn't flush output #3055

Closed
bjourne opened this issue Jul 25, 2023 · 4 comments
Closed

[BUG] Progress bar doesn't flush output #3055

bjourne opened this issue Jul 25, 2023 · 4 comments

Comments

@bjourne
Copy link

bjourne commented Jul 25, 2023

The progress bar doesn't automatically flush so at least in my terminal it appears stuck. MWE:

path = Path('psn.log')
size = path.stat().st_size
with open(path) as f:
    with wrap_file(f, size, description = 'Parsing...') as f:
        for line in f:
            #print('', end = '', flush = True)
            pass

Uncommenting the print makes the progress bar work, but makes the code run very slow since the terminal is updated once for every line. I only want to update the progress bar when the completion percentage changes. My workaround is to write this:

        for i, line in enumerate(f):
            if i % 10_000 == 0:
                print('', end = '', flush = True)

But it would be nicer if rich handled it automagically.

@github-actions
Copy link

Thank you for your issue. Give us a little time to review it.

PS. You might want to check the FAQ if you haven't done so already.

This is an automated reply, generated by FAQtory

@willmcgugan
Copy link
Collaborator

Please repost with the issue template filled in and an MRE. https://label.dev/articles/minimal-reproducible-example/

@github-actions
Copy link

I hope we solved your problem.

If you like using Rich, you might also enjoy Textual

@bjourne
Copy link
Author

bjourne commented Aug 13, 2023

See the snippet in the first comment. The non-flushing happens all the time with the wrap_file progress bar.

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