Logging chokes on BlockingIOError: write could not complete without blocking

Viewed 6669

I recently ported my scripts from 2.x to 3.x. During production runs through automation (rundeck) we are seeing errors caused by the logger not handling blocking I/O. Any ideas how to resolve would be great.

  • Ubuntu 18.04.1 LTS
  • Python 3.6.7
--- Logging error ---
Traceback (most recent call last):
  File "/usr/lib/python3.6/logging/__init__.py", line 998, in emit
    self.flush()
  File "/usr/lib/python3.6/logging/__init__.py", line 978, in flush
    self.stream.flush()
BlockingIOError: [Errno 11] write could not complete without blocking
2 Answers

I was getting the same error on CI builds. It looks like it was a capacity issue with the output stream. After reducing the log output, the errors went away.

I recently faced the error while building my Docker image using docker-compose in CI and I found one Workaround maybe that will help someone:

the Error:

BlockingIOError: [Errno 11] write could not complete without blocking

if you do not want to lose any logs , you can send all the logs to file and save it as an artifact , tested on Bamboo and Jenkins:

docker-compose build --no-cache my_image > myfile.txt

if you do not want the logs:

docker-compose build --no-cache my_image > /dev/null
Related