8000 [Feature Request] Option to Disable "Live" Progress Updates · Issue #1647 · tqdm/tqdm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
[Feature Request] Option to Disable "Live" Progress Updates #1647
Open
@liblaf

Description

@liblaf
  • I have marked all applicable categories:
    • documentation request (i.e. "X is missing from the documentation." If instead I want to ask "how to use X?" I understand StackOverflow#tqdm is more appropriate)
    • new feature request
  • I have visited the source website, and in particular
    read the known issues
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and
    environment, where applicable:
    import tqdm, sys
    print(tqdm.__version__, sys.version, sys.platform)

First of all, thank you for creating and maintaining such a fantastic library! It has been incredibly useful for tracking progress in my projects.

I'm encountering an issue where tqdm produces chaotic outputs when I print to stderr within a loop. I understand that live terminal rendering is complex, and I'd like to request a feature to completely disable the "live" updates. Instead, I'd prefer periodic stats to show the progress without carriage returns or live updates.

Here's a minimal example to illustrate the issue:

import sys
import time
from tqdm.contrib.bells import trange

for i in trange(4, ncols=80):
    time.sleep(0.1)
    print(i, file=sys.stderr)

This produces the following output:

  0%|                                                     | 0/4 [00:00<?, ?it/s]0
 25%|███████████▎                                 | 1/4 [00:00<00:00,  9.97it/s]1
 50%|██████████████████████▌                      | 2/4 [00:00<00:00,  9.97it/s]2
 75%|█████████████████████████████████▊           | 3/4 [00:00<00:00,  9.97it/s]3
100%|█████████████████████████████████████████████| 4/4 [00:00<00:00,  9.97it/s]

Environment:

  • tqdm: 4.67.1
  • python: 3.12.8
  • platform: linux
  • terminal: VS Code Terminal

The issue arises because tqdm uses carriage returns (\r) to update the progress bar live, which conflicts with the print statements to stderr. I’d like to propose an option to disable live updates entirely, so tqdm only prints periodic progress updates (e.g., at specific intervals or after each iteration) without overwriting the terminal line.

For example, the output could look like this instead:

  0%|                                                     | 0/4 [00:00<?, ?it/s]
0
 25%|███████████▎                                 | 1/4 [00:00<00:00,  9.97it/s]
1
 50%|██████████████████████▌                      | 2/4 [00:00<00:00,  9.97it/s]
2
 75%|█████████████████████████████████▊           | 3/4 [00:00<00:00,  9.97it/s]
3
100%|█████████████████████████████████████████████| 4/4 [00:00<00:00,  9.97it/s]

Would it be possible to add such a feature? For example, a parameter like live=False that disables live updates and only prints progress stats periodically?

Thank you again for your hard work on this library, and I look forward to your thoughts on this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0