From e249fd6c8d1fecf6a5262a71aeec62b074f909fa Mon Sep 17 00:00:00 2001 From: Arthur Goldberg Date: Fri, 30 Aug 2019 16:01:09 -0400 Subject: [PATCH] manage stderr more dynamically, to avoid failures like this that can occur when concurrent programs close & reopen stderr self = def is_tty(self): > return self.file.isatty() if self.check_tty else True E ValueError: I/O operation on closed file --- progress/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/progress/__init__.py b/progress/__init__.py index 596eea7..96b5d32 100644 --- a/progress/__init__.py +++ b/progress/__init__.py @@ -18,7 +18,7 @@ from collections import deque from datetime import timedelta from math import ceil -from sys import stderr +import sys try: from time import monotonic except ImportError: @@ -32,12 +32,12 @@ class Infinite(object): - file = stderr sma_window = 10 # Simple Moving Average window check_tty = True hide_cursor = True def __init__(self, message='', **kwargs): + self.file = sys.stderr self.index = 0 self.start_ts = monotonic() self.avg = 0