Skip to content

Flush stdin after writing to a pager #3242

@tucked

Description

@tucked

I would love to see text immediately in this toy example:

import click
import os
import time

def _generator():
    for i in range(10000):
        time.sleep(0.01)
        yield f"{i+1:07}\n"

@click.command
def main():
    os.environ.setdefault("LESS", "-XFR")
    click.echo_via_pager(_generator())

main()

As it is currently, nothing will show until 512 lines have been yielded.
I suspect a flush after this line would do the trick:

c.stdin.write(text)

Related: #2542 ☹️

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions