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

cli/colors: crash when importing if sys.stdout is closed #418

Closed
1 of 10 tasks
d4l3k opened this issue Mar 11, 2022 · 0 comments
Closed
1 of 10 tasks

cli/colors: crash when importing if sys.stdout is closed #418

d4l3k opened this issue Mar 11, 2022 · 0 comments
Labels
bug Something isn't working cli Related to the CLI

Comments

@d4l3k
Copy link
Member

d4l3k commented Mar 11, 2022

🐛 Bug

Sometimes sys.stdout is closed and isatty() throws an error at https://github.com/pytorch/torchx/blob/main/torchx/cli/colors.py#L11

Switching to a variant that checks if it's closed should work:

not sys.stdout.closed and sys.stdout.isatty()

Module (check all that applies):

  • torchx.spec
  • torchx.component
  • torchx.apps
  • torchx.runtime
  • torchx.cli
  • torchx.schedulers
  • torchx.pipelines
  • torchx.aws
  • torchx.examples
  • other

To Reproduce

I'm not sure how to repro this externally other than explicitly closing sys.stdout

I/O operation on closed file
Stack trace:
...
from torchx.cli.cmd_log import get_logs
File: <"/mnt/xarfuse/uid-27156/4adc7caa-seed-nspid4026533510_cgpid2017229-ns-4026533507/torchx/cli/cmd_log.py">, line 20, in <module>
from torchx.cli.colors import GREEN, ENDC
File: <"/mnt/xarfuse/uid-27156/4adc7caa-seed-nspid4026533510_cgpid2017229-ns-4026533507/torchx/cli/colors.py">, line 11, in <module>
if sys.stdout.isatty():

Expected behavior

Doesn't crash

Environment

  • torchx version (e.g. 0.1.0rc1): main
  • Python version:
  • OS (e.g., Linux):
  • How you installed torchx (conda, pip, source, docker):
  • Docker image and tag (if using docker):
  • Git commit (if installed from source):
  • Execution environment (on-prem, AWS, GCP, Azure etc):
  • Any other relevant information:

Additional context

@d4l3k d4l3k added bug Something isn't working cli Related to the CLI labels Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to the CLI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant