A workaround for Travis CI stdout "write error" or "Resource temporarily unavailable"
TL;DR
python2 -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
Add the line above at before_install
section of your .travis.yml
file.
Specifically, add this line before the line in your .travis.yml
which causes the error.
This problem won't happen in debug build.
Preface
One of my Travis CI build got tar: write error
while installing the gcloud SDK.
I was trying to find the reason in debug build, but got nothing.
Reason
EAGAIN
(errno 11) in Linux while dealing with non-blocking operations.
Lots of CLI tools expect stdout
is in blocking mode,
but it looks like Travis CI set stdout
to non-blocking mode in default.
These CLI tools (tar, make, ...) didn't handle EAGAIN
error well. (Should retry when got this error)
Solution
Add the line below before the line in your .travis.yml
which causes error.
You can also add it at before_install
section of your .travis.yml
.
python2 -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);'
For Python 3.5+:
python3 -c 'import os,sys; os.set_blocking(sys.stdout.fileno(), True)'
This will turn off the non-blocking mode for stdout.
References
Share
Donation
如果覺得這篇文章對你有幫助, 除了留言讓我知道外, 或許也可以考慮請我喝杯咖啡, 不論金額多寡我都會非常感激且能鼓勵我繼續寫出對你有幫助的文章。
If this blog post happens to be helpful to you, besides of leaving a reply, you may consider buy me a cup of coffee to support me. It would help me write more articles helpful to you in the future and I would really appreciate it.
Related Posts
- setuptools 36.2.0 upgrading/downgrading uninstall rollback error with Python 3.6.2 on Travis CI
- Change from Travis CI Build Matrix to Build Stages
- 用 Travis CI 自動化發佈 Pelican blog 到 GitHub Pages 上
- Y2016W26
- Docker + Travis CI + Kubernetes + GKE