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

Stop the ticker if the script is being run without a tty. #84

Merged
merged 2 commits into from
Mar 16, 2020

Conversation

mymatenige
Copy link
Contributor

At present the ticker can create output when it is being run without a tty. This creates messy and unusuable output for scripts, emails, etc. This change is a simple suggestion of how to clean this up.

…m from). Creates messy and unusuable output.
if sys.stderr.isatty():
# Start a ticker
ticker_thread = CommandTicker()
ticker_thread.start()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small request to make it a little less bugprone w/ changes in the future

ticker_thread = None
if sys.stderr.isatty():
    ticker_thread = CommandTicker()
    ticker_thread.start()

and

if ticker_thread is not None:
    ticker_thread.stop()
    ticker_thread.join()

It's helpful so that any changes to the condition in the future don't have risk of a bug where it's not propagated. The full state is encoded into the ticker_thread() object directly. Thanks!

@mymatenige
Copy link
Contributor Author

mymatenige commented Mar 16, 2020

Updated. Completely agree with suggestion.

@nipunn1313 nipunn1313 merged commit f075f53 into dropbox:master Mar 16, 2020
@mymatenige mymatenige deleted the bugfix-ticker-stderr branch March 16, 2020 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants