event.py: ignore exceptions from stdout and sterr operations in atexit
PATCH 1/1 event.py: ignore exceptions from stdout and sterr operations in atexit
From: Mikko Rapeli <[email protected]>
When atexit functions run, stdout and stderr operations may fail, e.g. when output is piped to less but has been exited by the user. This removes error print from output of "bitbake -e sqlite3 | less" if user presses "q" before bitbake has finished processing:
[Errno 32] Broken pipeError in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/home/builder/src/poky/bitbake/lib/bb/event.py", line 135, in print_ui_queue
sys.stdout.flush()
--- bitbake/lib/bb/event.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
bitbake/lib/bb/event.py +8 -2
@@ -132,8 +132,14 @@ def print_ui_queue(): if not _uiready: from bb.msg import BBLogFormatter # Flush any existing buffered content - sys.stdout.flush() - sys.stderr.flush() + try: + sys.stdout.flush() + except: + pass + try: + sys.stderr.flush() + except: + pass stdout = logging.StreamHandler(sys.stdout) stderr = logging.StreamHandler(sys.stderr) formatter = BBLogFormatter("%(levelname)s: %(message)s")
Signature · 1 line
2.20.1
Hi Mikko,
Quoted 19 lines · On Thu, 9 Jun 2022 08:56:10 +0300 "Mikko Rapeli" <[email protected]> wrote:
From: Mikko Rapeli <[email protected]>
When atexit functions run, stdout and stderr operations may fail, e.g. when output is piped to less but has been exited by the user. This removes error print from output of "bitbake -e sqlite3 | less" if user presses "q" before bitbake has finished processing:
[Errno 32] Broken pipeError in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/home/builder/src/poky/bitbake/lib/bb/event.py", line 135, inprint_ui_queue
sys.stdout.flush()Signed-off-by Mikko Rapeli <[email protected]>--- bitbake/lib/bb/event.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)bitbake/lib/bb/event.py +0
-0
bitbake/lib/bb/event.py
Quoted 1 line
bitbake/lib/bb/event.py +0
-1--- a/bitbake/lib/bb/event.py
^^^^^^^^
This patch does not apply on the bitbake tree due to the extra 'bitbake/' directory component. Perhaps you generated it from a poky tree instead?
I removed the extra component and applied it however, thus no need to resend, and also:
Signature · 3 lines
Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com