Skip to content

Generator command dumps the whole output at once when piped #145

Closed
@neithere

Description

@neithere

Example program

#!/usr/bin/python
from time import sleep

import argh

def main():
    for i in range(3):
        sleep(1)
        yield f'line {i}'

argh.dispatch_command(main)

Case A:

$ ./app.py
0
1
2

The output is printed line by line with pauses.

Case B:

$ ./app.py | tail -f
0
1
2

The output is the same but it's printed all at once after 3 seconds.

Another way to repro case B:

# in terminal 1:
$ touch app.log && tail -f app.log

# in terminal 2:
$ ./app.py > app.log

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions