You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:43:29 UTC

[buildstream] 01/01: _frontend/cli.py: Clear stdout/stderr fd flags at startup

This is an automated email from the ASF dual-hosted git repository.

root pushed a commit to branch tristan/spurious-blockingio-error
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 130cb6d3f7e8fb24567f053a8f87ef8e077f4c98
Author: Tristan Van Berkom <tr...@codethink.co.uk>
AuthorDate: Sat Feb 23 16:52:01 2019 +0900

    _frontend/cli.py: Clear stdout/stderr fd flags at startup
    
    This fixes #929
---
 buildstream/_frontend/cli.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index 02ca52e..f500f89 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -9,6 +9,7 @@ from .. import _yaml
 from .._exceptions import BstError, LoadError, AppError
 from .._versions import BST_FORMAT_VERSION
 from .complete import main_bashcomplete, complete_path, CompleteUnhandled
+import fcntl
 
 
 ##################################################################
@@ -170,6 +171,13 @@ def override_completions(orig_args, cmd, cmd_param, args, incomplete):
 def override_main(self, args=None, prog_name=None, complete_var=None,
                   standalone_mode=True, **extra):
 
+    # Clear file status flags, if stdout/stderr is open in non-blocking
+    # mode for some reason then this can cause BlockingIOError errors
+    # when trying to write to the file.
+    #
+    fcntl.fcntl(sys.stdout.fileno(), fcntl.F_SETFL, 0)
+    fcntl.fcntl(sys.stderr.fileno(), fcntl.F_SETFL, 0)
+
     # Hook for the Bash completion.  This only activates if the Bash
     # completion is actually enabled, otherwise this is quite a fast
     # noop.