Skip to content

mo.status.progress_bar shows wrong state when some updates are fast #10725

Description

@johannesacco

Describe the bug

There seem to be some throttling that cause an old state to be shown when some iterations are very fast. Using the internal marimo_output.flush() solves the problem, but I think that should not be needed.

Will you submit a PR?

  • Yes

Environment

{
"marimo": "0.24.0",
"editable": false,
"location": "...",
"OS": "Linux",
"OS Version": "7.0.0-30-generic",
"Processor": "x86_64",
"Python Version": "3.13.11",
"Locale": "en_US",
"Binaries": {
"Browser": "152.0.7977.64",
"Node": "--",
"uv": "0.11.7 (x86_64-unknown-linux-gnu)"
},
"Dependencies": {
"click": "8.4.2",
"docutils": "0.23",
"itsdangerous": "2.2.0",
"jedi": "0.19.2",
"markdown": "3.10.3",
"narwhals": "2.24.0",
"packaging": "26.3",
"psutil": "7.2.2",
"pygments": "2.20.0",
"pymdown-extensions": "10.21.3",
"pyyaml": "6.0.3",
"starlette": "1.6.0",
"tomlkit": "0.15.1",
"typing-extensions": "4.16.0",
"uvicorn": "0.52.1",
"websockets": "17.0.1"
},
"Optional Dependencies": {
"loro": "1.13.2",
"pandas": "3.0.5",
"pyarrow": "25.0.1",
"pytest": "9.0.3",
"ruff": "0.15.12"
},
"Experimental Flags": {}
}

Code to reproduce

In below example the progress bar shows "first" and "0/5" for 3 seconds even though it handles "first" and "second" very fast.

items = [(0, "first"),(0, "second"),(3, "third"),(0, "number 4"),(3, "last")]

with mo.status.progress_bar(
    total=len(items),
    title="Dummy test",
    remove_on_exit=True,
) as bar:
    for item in items:
        bar.update(increment=0, subtitle=item[1])
        await asyncio.sleep(item[0])

Adding a call to the internal marimo_output.flush() solves the problem:

import marimo._runtime.output._output as marimo_output

items = [(0, "first"),(0, "second"),(3, "third"),(0, "number 4"),(3, "last")]

with mo.status.progress_bar(
    total=len(items),
    title="Dummy test",
    remove_on_exit=True,
) as bar:
    for item in items:
        bar.update(increment=0, subtitle=item[1])
        marimo_output.flush()
        await asyncio.sleep(item[0])

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions