* [PATCH] process: Flush server stdout/stderr before reporting failure @ 2018-09-02 8:43 Jan Kiszka 2018-09-04 12:15 ` Richard Purdie 0 siblings, 1 reply; 6+ messages in thread From: Jan Kiszka @ 2018-09-02 8:43 UTC (permalink / raw) To: bitbake-devel We need to print exceptions and flush output channels before telling the client that the server failed. Otherwise the daemon log file may still be empty when the client opens it for printing. This fixes error reporting when the output is redirected to a pipe, e.g. "bitbake target | cat" with a syntax error in a recipes or config file. That's specifically annoying when bitbake is under the control of a frontend process such as kas. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> --- lib/bb/server/process.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py index 9e5e709f..bcc4eb40 100644 --- a/lib/bb/server/process.py +++ b/lib/bb/server/process.py @@ -29,6 +29,7 @@ import array import os import sys import time +import traceback import select import socket import subprocess @@ -435,7 +436,11 @@ class BitBakeServer(object): try: self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset) writer.send("ready") - except: + except (Exception, SystemExit) as e: + if type(e) != SystemExit: + traceback.print_exc() + sys.stdout.flush() + sys.stderr.flush() writer.send("fail") raise finally: -- 2.16.4 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] process: Flush server stdout/stderr before reporting failure 2018-09-02 8:43 [PATCH] process: Flush server stdout/stderr before reporting failure Jan Kiszka @ 2018-09-04 12:15 ` Richard Purdie 2018-09-04 12:34 ` Richard Purdie 0 siblings, 1 reply; 6+ messages in thread From: Richard Purdie @ 2018-09-04 12:15 UTC (permalink / raw) To: Jan Kiszka, bitbake-devel On Sun, 2018-09-02 at 10:43 +0200, Jan Kiszka wrote: > We need to print exceptions and flush output channels before telling > the > client that the server failed. Otherwise the daemon log file may > still > be empty when the client opens it for printing. > > This fixes error reporting when the output is redirected to a pipe, > e.g. > "bitbake target | cat" with a syntax error in a recipes or config > file. > That's specifically annoying when bitbake is under the control of a > frontend process such as kas. Hi, Could you check if this was already fixed by: http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=cbe2d3cb0af6c7a5cd368e7dc489960a13648bd0 ? I really want to get these flushes as close to the source of the problems as we can. Cheers, Richard ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] process: Flush server stdout/stderr before reporting failure 2018-09-04 12:15 ` Richard Purdie @ 2018-09-04 12:34 ` Richard Purdie 2018-09-04 13:09 ` Jan Kiszka 0 siblings, 1 reply; 6+ messages in thread From: Richard Purdie @ 2018-09-04 12:34 UTC (permalink / raw) To: Jan Kiszka, bitbake-devel On Tue, 2018-09-04 at 13:15 +0100, Richard Purdie wrote: > On Sun, 2018-09-02 at 10:43 +0200, Jan Kiszka wrote: > > We need to print exceptions and flush output channels before > > telling > > the > > client that the server failed. Otherwise the daemon log file may > > still > > be empty when the client opens it for printing. > > > > This fixes error reporting when the output is redirected to a pipe, > > e.g. > > "bitbake target | cat" with a syntax error in a recipes or config > > file. > > That's specifically annoying when bitbake is under the control of a > > frontend process such as kas. > > Hi, > > Could you check if this was already fixed by: > > http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=cbe2d3cb0af6c7a5 > cd368e7dc489960a13648bd0 > > ? > > I really want to get these flushes as close to the source of the > problems as we can. Looking at the code further, I suspect we should simply be doing: writer = ConnectionWriter(self.readypipein) self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset) writer.send("ready") os.close(self.readypipein) server.cooker = self.cooker with no exception handling. The ready pipe would then get closed by the os._exit() in daemonize which is after the flush. It simplifies the code as an added bonus... Cheers, Richard ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] process: Flush server stdout/stderr before reporting failure 2018-09-04 12:34 ` Richard Purdie @ 2018-09-04 13:09 ` Jan Kiszka 2018-09-05 0:14 ` richard.purdie 0 siblings, 1 reply; 6+ messages in thread From: Jan Kiszka @ 2018-09-04 13:09 UTC (permalink / raw) To: Richard Purdie, bitbake-devel On 2018-09-04 14:34, Richard Purdie wrote: > On Tue, 2018-09-04 at 13:15 +0100, Richard Purdie wrote: >> On Sun, 2018-09-02 at 10:43 +0200, Jan Kiszka wrote: >>> We need to print exceptions and flush output channels before >>> telling >>> the >>> client that the server failed. Otherwise the daemon log file may >>> still >>> be empty when the client opens it for printing. >>> >>> This fixes error reporting when the output is redirected to a pipe, >>> e.g. >>> "bitbake target | cat" with a syntax error in a recipes or config >>> file. >>> That's specifically annoying when bitbake is under the control of a >>> frontend process such as kas. >> >> Hi, >> >> Could you check if this was already fixed by: >> >> http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=cbe2d3cb0af6c7a5 >> cd368e7dc489960a13648bd0 Looks similar on first glance, but it only partly helps with exceptions. We get from $ bitbake | cat ERROR: Unable to start bitbake server to $ bitbake | cat ERROR: Unable to start bitbake server ERROR: Server log for this session (/work/build/bitbake-cookerdaemon.log): --- Starting bitbake server pid 149 at 2018-09-04 13:02:15.144583 --- while it should have $ bitbake ERROR: Unable to start bitbake server ERROR: Last 10 lines of server log for this session (/work/build/bitbake-cookerdaemon.log): Traceback (most recent call last): File "/work/isar/bitbake/lib/bb/daemonize.py", line 77, in createDaemon function() File "/work/isar/bitbake/lib/bb/server/process.py", line 433, in _startServer self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset) File "/work/isar/bitbake/lib/bb/cooker.py", line 178, in __init__ self.configwatcher = pyinotify.WatchManager() File "/work/isar/bitbake/lib/pyinotify.py", line 1764, in __init__ raise OSError(err % self._inotify_wrapper.str_errno()) OSError: Cannot initialize new instance of inotify, Errno=Too many open files (EMFILE) >> >> ? >> >> I really want to get these flushes as close to the source of the >> problems as we can. > > Looking at the code further, I suspect we should simply be doing: > > writer = ConnectionWriter(self.readypipein) > self.cooker = bb.cooker.BBCooker(self.configuration, self.featureset) > writer.send("ready") > os.close(self.readypipein) > server.cooker = self.cooker > > with no exception handling. The ready pipe would then get closed by the > os._exit() in daemonize which is after the flush. It simplifies the > code as an added bonus... Tried that, but it does not work that way, it just hangs. As I wrote, the test case is trivial: just direct the output of bitbake into a pipe (bitbake | cat). Jan ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] process: Flush server stdout/stderr before reporting failure 2018-09-04 13:09 ` Jan Kiszka @ 2018-09-05 0:14 ` richard.purdie 2018-09-07 9:48 ` Jan Kiszka 0 siblings, 1 reply; 6+ messages in thread From: richard.purdie @ 2018-09-05 0:14 UTC (permalink / raw) To: Jan Kiszka, bitbake-devel On Tue, 2018-09-04 at 15:09 +0200, Jan Kiszka wrote: > Looks similar on first glance, but it only partly helps with > exceptions. > We get from > > $ bitbake | cat > ERROR: Unable to start bitbake server > > to > > $ bitbake | cat > ERROR: Unable to start bitbake server > ERROR: Server log for this session (/work/build/bitbake- > cookerdaemon.log): > --- Starting bitbake server pid 149 at 2018-09-04 13:02:15.144583 --- > > while it should have > > $ bitbake > ERROR: Unable to start bitbake server > ERROR: Last 10 lines of server log for this session > (/work/build/bitbake-cookerdaemon.log): > Traceback (most recent call last): > File "/work/isar/bitbake/lib/bb/daemonize.py", line 77, in > createDaemon > function() > File "/work/isar/bitbake/lib/bb/server/process.py", line 433, in > _startServer > self.cooker = bb.cooker.BBCooker(self.configuration, > self.featureset) > File "/work/isar/bitbake/lib/bb/cooker.py", line 178, in __init__ > self.configwatcher = pyinotify.WatchManager() > File "/work/isar/bitbake/lib/pyinotify.py", line 1764, in __init__ > raise OSError(err % self._inotify_wrapper.str_errno()) > OSError: Cannot initialize new instance of inotify, Errno=Too many > open > files (EMFILE) The more I looked into this the more problems I found. I've put this in for some testing which should address the issues: http://git.yoctoproject.org/cgit.cgi/poky/commit/?h=master-next&id=dae574dd680f4f9db0b1447266742fa127963842 Cheers, Richard ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] process: Flush server stdout/stderr before reporting failure 2018-09-05 0:14 ` richard.purdie @ 2018-09-07 9:48 ` Jan Kiszka 0 siblings, 0 replies; 6+ messages in thread From: Jan Kiszka @ 2018-09-07 9:48 UTC (permalink / raw) To: richard.purdie, bitbake-devel On 2018-09-05 02:14, richard.purdie@linuxfoundation.org wrote: > On Tue, 2018-09-04 at 15:09 +0200, Jan Kiszka wrote: >> Looks similar on first glance, but it only partly helps with >> exceptions. >> We get from >> >> $ bitbake | cat >> ERROR: Unable to start bitbake server >> >> to >> >> $ bitbake | cat >> ERROR: Unable to start bitbake server >> ERROR: Server log for this session (/work/build/bitbake- >> cookerdaemon.log): >> --- Starting bitbake server pid 149 at 2018-09-04 13:02:15.144583 --- >> >> while it should have >> >> $ bitbake >> ERROR: Unable to start bitbake server >> ERROR: Last 10 lines of server log for this session >> (/work/build/bitbake-cookerdaemon.log): >> Traceback (most recent call last): >> File "/work/isar/bitbake/lib/bb/daemonize.py", line 77, in >> createDaemon >> function() >> File "/work/isar/bitbake/lib/bb/server/process.py", line 433, in >> _startServer >> self.cooker = bb.cooker.BBCooker(self.configuration, >> self.featureset) >> File "/work/isar/bitbake/lib/bb/cooker.py", line 178, in __init__ >> self.configwatcher = pyinotify.WatchManager() >> File "/work/isar/bitbake/lib/pyinotify.py", line 1764, in __init__ >> raise OSError(err % self._inotify_wrapper.str_errno()) >> OSError: Cannot initialize new instance of inotify, Errno=Too many >> open >> files (EMFILE) > > The more I looked into this the more problems I found. I've put this in > for some testing which should address the issues: > > http://git.yoctoproject.org/cgit.cgi/poky/commit/?h=master-next&id=dae574dd680f4f9db0b1447266742fa127963842 > Yep, it does here as well! Thanks, Jan -- Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-09-07 9:48 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-09-02 8:43 [PATCH] process: Flush server stdout/stderr before reporting failure Jan Kiszka 2018-09-04 12:15 ` Richard Purdie 2018-09-04 12:34 ` Richard Purdie 2018-09-04 13:09 ` Jan Kiszka 2018-09-05 0:14 ` richard.purdie 2018-09-07 9:48 ` Jan Kiszka
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.