bitbake: cooker: Use event to terminate parser threads

Uses an event to terminate the parser threads instead of a queue. This
is not only simpler, but saves about 500ms on shutdown time

(Bitbake rev: 2aed34e1d4bf24bba6263f168ff31b55b5fbe982)

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Joshua Watt 2022-11-29 14:00:12 -06:00 committed by Richard Purdie
parent 8fe5f307e2
commit 1e7cb630c7

View File

@ -2093,11 +2093,7 @@ class Parser(multiprocessing.Process):
pending = []
try:
while True:
try:
self.quit.get_nowait()
except queue.Empty:
pass
else:
if self.quit.is_set():
break
if pending:
@ -2194,7 +2190,7 @@ class CookerParser(object):
if self.toparse:
bb.event.fire(bb.event.ParseStarted(self.toparse), self.cfgdata)
self.parser_quit = multiprocessing.Queue(maxsize=self.num_processes)
self.parser_quit = multiprocessing.Event()
self.result_queue = multiprocessing.Queue()
def chunkify(lst,n):
@ -2226,8 +2222,7 @@ class CookerParser(object):
else:
bb.error("Parsing halted due to errors, see error messages above")
for process in self.processes:
self.parser_quit.put(None)
self.parser_quit.set()
# Cleanup the queue before call process.join(), otherwise there might be
# deadlocks.
@ -2257,10 +2252,6 @@ class CookerParser(object):
if hasattr(process, "close"):
process.close()
self.parser_quit.close()
# Allow data left in the cancel queue to be discarded
self.parser_quit.cancel_join_thread()
def sync_caches():
for c in self.bb_caches.values():
c.sync()