diff options
author | Max Romanov <max.romanov@nginx.com> | 2020-07-22 10:05:10 +0300 |
---|---|---|
committer | Max Romanov <max.romanov@nginx.com> | 2020-07-22 10:05:10 +0300 |
commit | 661c223eda641eeb2ee02db3d1e1cd4e5cd583f7 (patch) | |
tree | 19530866fb36da3132e4e15e070230241650a84c | |
parent | ef7194819662975f53822ac27a071bf00259e38e (diff) | |
download | unit-661c223eda641eeb2ee02db3d1e1cd4e5cd583f7.tar.gz unit-661c223eda641eeb2ee02db3d1e1cd4e5cd583f7.tar.bz2 |
Tests: switching stdout to blocking before printing log.
This is another attempt to fix the following error message:
BlockingIOError: [Errno 11] write could not complete without blocking
-rw-r--r-- | test/unit/main.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/test/unit/main.py b/test/unit/main.py index 408cf31c..8bca888c 100644 --- a/test/unit/main.py +++ b/test/unit/main.py @@ -407,8 +407,11 @@ class TestUnit(unittest.TestCase): print('Path to unit.log:\n' + path + '\n') if TestUnit.print_log: + os.set_blocking(sys.stdout.fileno(), True) + sys.stdout.flush() + if data is None: with open(path, 'r', encoding='utf-8', errors='ignore') as f: - data = f.read() - - print(data) + shutil.copyfileobj(f, sys.stdout) + else: + sys.stdout.write(data) |