diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2022-11-29 14:00:12 -0600 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-12-08 10:49:53 +0000 |
commit | 1e7cb630c7c53c991603cc8c132a6dcbc2e5fe34 (patch) | |
tree | 82be4be8e450475e602d1bfcfc5cc69050655bfc /bitbake | |
parent | 8fe5f307e2921e3ecf46e2b45f89fd1982680315 (diff) | |
download | poky-1e7cb630c7c53c991603cc8c132a6dcbc2e5fe34.tar.gz |
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>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 15 |
1 files changed, 3 insertions, 12 deletions
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): | |||
2093 | pending = [] | 2093 | pending = [] |
2094 | try: | 2094 | try: |
2095 | while True: | 2095 | while True: |
2096 | try: | 2096 | if self.quit.is_set(): |
2097 | self.quit.get_nowait() | ||
2098 | except queue.Empty: | ||
2099 | pass | ||
2100 | else: | ||
2101 | break | 2097 | break |
2102 | 2098 | ||
2103 | if pending: | 2099 | if pending: |
@@ -2194,7 +2190,7 @@ class CookerParser(object): | |||
2194 | if self.toparse: | 2190 | if self.toparse: |
2195 | bb.event.fire(bb.event.ParseStarted(self.toparse), self.cfgdata) | 2191 | bb.event.fire(bb.event.ParseStarted(self.toparse), self.cfgdata) |
2196 | 2192 | ||
2197 | self.parser_quit = multiprocessing.Queue(maxsize=self.num_processes) | 2193 | self.parser_quit = multiprocessing.Event() |
2198 | self.result_queue = multiprocessing.Queue() | 2194 | self.result_queue = multiprocessing.Queue() |
2199 | 2195 | ||
2200 | def chunkify(lst,n): | 2196 | def chunkify(lst,n): |
@@ -2226,8 +2222,7 @@ class CookerParser(object): | |||
2226 | else: | 2222 | else: |
2227 | bb.error("Parsing halted due to errors, see error messages above") | 2223 | bb.error("Parsing halted due to errors, see error messages above") |
2228 | 2224 | ||
2229 | for process in self.processes: | 2225 | self.parser_quit.set() |
2230 | self.parser_quit.put(None) | ||
2231 | 2226 | ||
2232 | # Cleanup the queue before call process.join(), otherwise there might be | 2227 | # Cleanup the queue before call process.join(), otherwise there might be |
2233 | # deadlocks. | 2228 | # deadlocks. |
@@ -2257,10 +2252,6 @@ class CookerParser(object): | |||
2257 | if hasattr(process, "close"): | 2252 | if hasattr(process, "close"): |
2258 | process.close() | 2253 | process.close() |
2259 | 2254 | ||
2260 | self.parser_quit.close() | ||
2261 | # Allow data left in the cancel queue to be discarded | ||
2262 | self.parser_quit.cancel_join_thread() | ||
2263 | |||
2264 | def sync_caches(): | 2255 | def sync_caches(): |
2265 | for c in self.bb_caches.values(): | 2256 | for c in self.bb_caches.values(): |
2266 | c.sync() | 2257 | c.sync() |