Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writes to stdout during hidden state of the spinner should be flushed somehow #14

Open
pavdmyt opened this issue Mar 25, 2018 · 0 comments

Comments

@pavdmyt
Copy link
Owner

pavdmyt commented Mar 25, 2018

Writes to stdout when spinner is in hidden state (using Yaspin.hide) should explicitly contain a newline character \n in order to flush the stdout. Consider this example:

import sys
import time

from yaspin import yaspin

with yaspin(text='Downloading images') as sp:
    # task 1
    time.sleep(1)
    sp.hide()
    sys.stdout.write('> image 1 download complete\n')
    sp.show()

    # task 2
    time.sleep(2)
    sp.hide()
    sys.stdout.write('> image 2 download complete\n')
    sp.show()

It is desirable that library handles this by itself. One of the possible approach is to monitor stdout of the process which utilizes yaspin. Here some relevant discussions I've found:

Somewhat similar functionality is also implemented in capsys fixture from pytest.

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

No branches or pull requests

1 participant