Skip to content

[BUG] Progress bar with auto_refresh=False about 30x slower #1536

@goldstar611

Description

@goldstar611

Read the docs
I have read all of https://rich.readthedocs.io/en/latest/progress.html

Describe the bug
When I create a progress bar with auto_refresh=False the worker loop seems to be about 30 - 40 times slower

With auto_refresh=True the ETA is about 1.5 minutes

Working... ╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   2% 0:01:37

And with auto_refresh=False the ETA is 38 minutes.

Working... ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━   1% 0:38:17

To Reproduce

#!/usr/bin/env python3

import time
from rich.progress import Progress

lines = range(1*10**6)

for auto_refresh in [True, False]:
    with Progress(auto_refresh=auto_refresh) as progress:
        task = progress.add_task("Working...", visible=True, total=len(lines))
        for line in lines:
            progress.update(task, advance=1)
            if not auto_refresh:
                progress.refresh()
            time.sleep(0.00001)

Platform
Mac BigSur (10.15.2)
Python 3.9.7

Diagnose
I may ask you to cut and paste the output of the following commands. It may save some time if you do it now.

python -m rich.diagnose

╭───────────────────────── <class 'rich.console.Console'> ─────────────────────────╮
│ A high level console interface.                                                  │
│                                                                                  │
│ ╭──────────────────────────────────────────────────────────────────────────────╮ │
│ │ <console width=236 ColorSystem.EIGHT_BIT>                                    │ │
│ ╰──────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                  │
│     color_system = '256'                                                         │
│         encoding = 'utf-8'                                                       │
│             file = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'> │
│           height = 51                                                            │
│    is_alt_screen = False                                                         │
│ is_dumb_terminal = False                                                         │
│   is_interactive = True                                                          │
│       is_jupyter = False                                                         │
│      is_terminal = True                                                          │
│   legacy_windows = False                                                         │
│         no_color = False                                                         │
│          options = ConsoleOptions(                                               │
│                        size=ConsoleDimensions(width=236, height=51),             │
│                        legacy_windows=False,                                     │
│                        min_width=1,                                              │
│                        max_width=236,                                            │
│                        is_terminal=True,                                         │
│                        encoding='utf-8',                                         │
│                        max_height=51,                                            │
│                        justify=None,                                             │
│                        overflow=None,                                            │
│                        no_wrap=False,                                            │
│                        highlight=None,                                           │
│                        markup=None,                                              │
│                        height=None                                               │
│                    )                                                             │
│            quiet = False                                                         │
│           record = False                                                         │
│         safe_box = True                                                          │
│             size = ConsoleDimensions(width=236, height=51)                       │
│        soft_wrap = False                                                         │
│           stderr = False                                                         │
│            style = None                                                          │
│         tab_size = 8                                                             │
│            width = 236                                                           │
╰──────────────────────────────────────────────────────────────────────────────────╯

python -m rich._windows

platform="Darwin"
WindowsConsoleFeatures(vt=False, truecolor=False)

pip freeze | grep rich
rich==10.11.0


**Did I help?**

If I was able to resolve your problem, consider [sponsoring](https://github.com/sponsors/willmcgugan) my work on Rich, or [buy me a coffee](https://ko-fi.com/willmcgugan) to say thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions