From 1e7cb630c7c53c991603cc8c132a6dcbc2e5fe34 Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Tue, 29 Nov 2022 14:00:12 -0600 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/cooker.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'bitbake/lib/bb/cooker.py') diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 4be95dd7fb..7f232f2b36 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -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() -- cgit v1.2.3-54-g00ecf