knotty: shut down more cleanly

This ensures that when we are shutting down, we drain the queue of events from
the server. This ensures that the server never gets hung up on the join of the
feeder thread associated with the event queue, thereby avoiding a bitbake hang
issue.

Also, since the third keyboard interrupt now behaves the same as the second,
removed that message.

(Bitbake rev: ce9e0946b8a412616074809c76fba54f8bff36c4)

Signed-off-by: Christopher Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Christopher Larson
2012-02-07 12:07:40 -06:00
committed by Richard Purdie
parent cf60f95d9f
commit 52ebd5ff1b

View File

@@ -118,6 +118,8 @@ def main(server, eventHandler):
try: try:
event = eventHandler.waitEvent(0.25) event = eventHandler.waitEvent(0.25)
if event is None: if event is None:
if shutdown > 1:
break
continue continue
helper.eventHandler(event) helper.eventHandler(event)
if isinstance(event, bb.runqueue.runQueueExitWait): if isinstance(event, bb.runqueue.runQueueExitWait):
@@ -199,18 +201,18 @@ def main(server, eventHandler):
print("Loaded %d entries from dependency cache." % event.num_entries) print("Loaded %d entries from dependency cache." % event.num_entries)
continue continue
if isinstance(event, bb.command.CommandCompleted):
break
if isinstance(event, bb.command.CommandFailed): if isinstance(event, bb.command.CommandFailed):
return_value = event.exitcode return_value = event.exitcode
logger.error("Command execution failed: %s", event.error) logger.error("Command execution failed: %s", event.error)
break shutdown = 2
continue
if isinstance(event, bb.command.CommandExit): if isinstance(event, bb.command.CommandExit):
if not return_value: if not return_value:
return_value = event.exitcode return_value = event.exitcode
continue continue
if isinstance(event, bb.cooker.CookerExit): if isinstance(event, (bb.command.CommandCompleted, bb.cooker.CookerExit)):
break shutdown = 2
continue
if isinstance(event, bb.event.MultipleProviders): if isinstance(event, bb.event.MultipleProviders):
logger.info("multiple providers are available for %s%s (%s)", event._is_runtime and "runtime " or "", logger.info("multiple providers are available for %s%s (%s)", event._is_runtime and "runtime " or "",
event._item, event._item,
@@ -269,9 +271,6 @@ def main(server, eventHandler):
if ioerror.args[0] == 4: if ioerror.args[0] == 4:
pass pass
except KeyboardInterrupt: except KeyboardInterrupt:
if shutdown == 2:
print("\nThird Keyboard Interrupt, exit.\n")
break
if shutdown == 1: if shutdown == 1:
print("\nSecond Keyboard Interrupt, stopping...\n") print("\nSecond Keyboard Interrupt, stopping...\n")
server.runCommand(["stateStop"]) server.runCommand(["stateStop"])