diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-06-15 12:00:31 -1000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-06-19 17:06:14 +0100 |
commit | 6d2dd16b87ce62086f956912e9a7335b2adfcc94 (patch) | |
tree | b6dfde5ee6603a9c5ceabd8dba946f1dcd4c1a2f | |
parent | 1dcc4e29dee3fd0dd4d6dc2fc9ccdc5888fcfcf3 (diff) | |
download | bitbake-6d2dd16b87ce62086f956912e9a7335b2adfcc94.tar.gz |
cooker: Explictly shut down the sync thread
Hongxu Jia reported a problem where the bb_cache files were not always being
written out correctly. This was due to the sync thread being terminated
prematurely.
Whilst the preceeding changes mean the exit handler for this thread is now
correctly called since we switch to using sys.exit() instead of os._exit(),
this write can happen after we drop the bitbake lock, leading to potential
races. Avoid that headache by adding in explicit thread join() calls before
we drop the lock (which atexit or Finalize can't do).
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/cooker.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py index 4820d268e..878845742 100644 --- a/lib/bb/cooker.py +++ b/lib/bb/cooker.py @@ -1650,6 +1650,7 @@ class BBCooker: if self.parser: self.parser.shutdown(clean=not force, force=force) + self.parser.final_cleanup() def finishcommand(self): self.state = state.initial @@ -2015,6 +2016,7 @@ class CookerParser(object): self.start() self.haveshutdown = False + self.syncthread = None def start(self): self.results = self.load_cached() @@ -2081,8 +2083,8 @@ class CookerParser(object): self.parser_quit.join_thread() sync = threading.Thread(target=self.bb_cache.sync) + self.syncthread = sync sync.start() - multiprocessing.util.Finalize(None, sync.join, exitpriority=-100) bb.codeparser.parser_cache_savemerge() bb.fetch.fetcher_parse_done() if self.cooker.configuration.profile: @@ -2096,6 +2098,10 @@ class CookerParser(object): bb.utils.process_profilelog(profiles, pout = pout) print("Processed parsing statistics saved to %s" % (pout)) + def final_cleanup(self): + if self.syncthread: + self.syncthread.join() + def load_cached(self): for filename, appends in self.fromcache: cached, infos = self.bb_cache.load(filename, appends) |