Skip to content

Commit f9aa7ed

Browse files
committed
Merge branch 'release/3.53.0'
2 parents 3715044 + 08bf420 commit f9aa7ed

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

progressbar/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
long running operations.
2020
'''.strip().split())
2121
__email__ = '[email protected]'
22-
__version__ = '3.52.1'
22+
__version__ = '3.53.0'
2323
__license__ = 'BSD'
2424
__copyright__ = 'Copyright 2015 Rick van Hattem (Wolph)'
2525
__url__ = 'https://github.com/WoLpH/python-progressbar'

progressbar/utils.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import absolute_import
22
import distutils.util
3+
import atexit
34
import io
45
import os
56
import re
@@ -193,12 +194,14 @@ def __init__(self, target, capturing=False, listeners=set()):
193194
def write(self, value):
194195
if self.capturing:
195196
self.buffer.write(value)
196-
if '\n' in value:
197+
if '\n' in value: # pragma: no branch
197198
self.needs_clear = True
198199
for listener in self.listeners: # pragma: no branch
199200
listener.update()
200201
else:
201202
self.target.write(value)
203+
if '\n' in value:
204+
self.flush_target()
202205

203206
def flush(self):
204207
self.buffer.flush()
@@ -212,6 +215,13 @@ def _flush(self):
212215
self.buffer.truncate(0)
213216
self.needs_clear = False
214217

218+
# when explicitly flushing, always flush the target as well
219+
self.flush_target()
220+
221+
def flush_target(self): # pragma: no cover
222+
if not self.target.closed and getattr(self.target, 'flush'):
223+
self.target.flush()
224+
215225

216226
class StreamWrapper(object):
217227
'''Wrap stdout and stderr globally'''
@@ -406,3 +416,4 @@ def __delattr__(self, name):
406416

407417
logger = logging.getLogger(__name__)
408418
streams = StreamWrapper()
419+
atexit.register(streams.flush)

0 commit comments

Comments
 (0)