summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2013-08-27 15:12:55 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-28 00:25:56 +0100
commitda6260f95f4adcca22da9b0d5fb26e93c0a2517f (patch)
tree7c96d166ced533d2655249962962f08bc0b74496 /bitbake/lib
parentc2533fb7179d6ac8b90155210b37edb784d644c9 (diff)
downloadpoky-da6260f95f4adcca22da9b0d5fb26e93c0a2517f.tar.gz
bitbake: serv.py: Fix hang when spawned dynamically with bitbake
The PRServer has the possibility to hang indefinitely blocking on a semaphore processing a xmlrpc request to send an event back to the main bitbake instance. This was observed during a "bitbake -e" on a heavily loaded machine and the main bitbake instance and cooker exited before the PRServer emitted its first log. The stack trace is provided below as to show what happens every time a logger.info() is executed in the PRServer. Not only does it write to the stream handler but it also tries to send the event to the main event processor. self._notempty.acquire() self.queue.put(event) _ui_handlers[h].event.send(event) fire_ui_handlers(event, d) fire(record, None) self.emit(record) hdlr.handle(record) self.callHandlers(record) self.handle(record) self._log(INFO, msg, args, **kwargs) (self.dbfile, self.host, self.port, str(os.getpid()))) self.work_forever() pid = self.daemonize() self.prserv.start() singleton.start() self.prhost = prserv.serv.auto_start(self.data) cooker.pre_serve() bb.cooker.server_main(self.cooker, self.main) self.run() code = process_obj._bootstrap() self._popen = Popen(self) self.serverImpl.start() server.detach() server = start_server(servermodule, configParams, configuration) ret = main() It was never intended for the PRServer to send its logs anywhere but its own log file. The event processing is an artifact of how the PRServer was forked and it inherits the event log handlers. The simple fix is to clean up and purge all the log handlers after the fork() but before doing any of the typical PRServer work or logging. (Bitbake rev: 972bc43e6d5b1207b944b3baa8f9805adb35dda7) Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/prserv/serv.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 81b4f8d069..781f0545d6 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -143,6 +143,11 @@ class PRServer(SimpleXMLRPCServer):
143 os.dup2(so.fileno(),sys.stdout.fileno()) 143 os.dup2(so.fileno(),sys.stdout.fileno())
144 os.dup2(se.fileno(),sys.stderr.fileno()) 144 os.dup2(se.fileno(),sys.stderr.fileno())
145 145
146 # Clear out all log handlers prior to the fork() to avoid calling
147 # event handlers not part of the PRserver
148 for logger_iter in logging.Logger.manager.loggerDict.keys():
149 logger_iter.handlers = []
150
146 # Ensure logging makes it to the logfile 151 # Ensure logging makes it to the logfile
147 streamhandler = logging.StreamHandler() 152 streamhandler = logging.StreamHandler()
148 streamhandler.setLevel(logging.DEBUG) 153 streamhandler.setLevel(logging.DEBUG)