1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 13:09:50 +00:00

bitbake: process: Further improve robustness against server shutdown

Currently, if an exception occurs in an event handler, the server shuts
down but the UI simply hangs. This happens in two places, firstly waiting
for events and secondly, sending events to a server which no longer exists.

The latter does time out, the former does not. These patches improve
both code sections to check if the main server process is alive and if not,
trigger things to shut down gracefully. This avoids the timeout in the
command sending case too.

This resolves various cases where the UI would simply hang indefintely.

(Bitbake rev: ac418e1112ff5f9c3157569316902f7a27fba4b4)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2014-08-21 10:27:10 +01:00
parent 8683c244c1
commit d33cc89e53
+14 -3
View File
@@ -38,14 +38,18 @@ from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer
logger = logging.getLogger('BitBake') logger = logging.getLogger('BitBake')
class ServerCommunicator(): class ServerCommunicator():
def __init__(self, connection, event_handle): def __init__(self, connection, event_handle, server):
self.connection = connection self.connection = connection
self.event_handle = event_handle self.event_handle = event_handle
self.server = server
def runCommand(self, command): def runCommand(self, command):
# @todo try/except # @todo try/except
self.connection.send(command) self.connection.send(command)
if not self.server.is_alive():
raise SystemExit
while True: while True:
# don't let the user ctrl-c while we're waiting for a response # don't let the user ctrl-c while we're waiting for a response
try: try:
@@ -160,7 +164,7 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
self.procserver = serverImpl self.procserver = serverImpl
self.ui_channel = ui_channel self.ui_channel = ui_channel
self.event_queue = event_queue self.event_queue = event_queue
self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle) self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle, self.procserver)
self.events = self.event_queue self.events = self.event_queue
def sigterm_terminate(self): def sigterm_terminate(self):
@@ -199,14 +203,20 @@ class ProcessEventQueue(multiprocessing.queues.Queue):
def waitEvent(self, timeout): def waitEvent(self, timeout):
if self.exit: if self.exit:
raise KeyboardInterrupt() raise SystemExit
try: try:
if not self.server.is_alive():
self.setexit()
return None
return self.get(True, timeout) return self.get(True, timeout)
except Empty: except Empty:
return None return None
def getEvent(self): def getEvent(self):
try: try:
if not self.server.is_alive():
self.setexit()
return None
return self.get(False) return self.get(False)
except Empty: except Empty:
return None return None
@@ -221,6 +231,7 @@ class BitBakeServer(BitBakeBaseServer):
self.ui_channel, self.server_channel = Pipe() self.ui_channel, self.server_channel = Pipe()
self.event_queue = ProcessEventQueue(0) self.event_queue = ProcessEventQueue(0)
self.serverImpl = ProcessServer(self.server_channel, self.event_queue, None) self.serverImpl = ProcessServer(self.server_channel, self.event_queue, None)
self.event_queue.server = self.serverImpl
def detach(self): def detach(self):
self.serverImpl.start() self.serverImpl.start()