Skip to content

Commit db68400

Browse files
author
Russell
committed
Added PYTHONUNBUFFERED=x by default.
1 parent 913895d commit db68400

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

python/apollocaffe/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,17 @@ def base_parser():
3232
return parser
3333

3434
set_cpp_loglevel(3)
35+
36+
# Apollocaffe uses print() over the obscure python logging module
37+
# Disable buffering of stdout ,equivalent to export PYTHONUNBUFFERED=x
38+
class Unbuffered(object):
39+
def __init__(self, stream):
40+
self.stream = stream
41+
def write(self, data):
42+
self.stream.write(data)
43+
self.stream.flush()
44+
def __getattr__(self, attr):
45+
return getattr(self.stream, attr)
46+
47+
import sys
48+
sys.stdout = Unbuffered(sys.stdout)

0 commit comments

Comments
 (0)