summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-22 15:12:15 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-08-23 00:00:04 +0100
commitafd1900939f7b042297558f4cb01f50f3a299267 (patch)
treee4e53ff69cf25cadfd8f66292fe53e5523dd865f
parent51ba35e9bbd4da8b5f3b3b5b8213cb634a6b0f06 (diff)
downloadbitbake-afd1900939f7b042297558f4cb01f50f3a299267.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>
-rw-r--r--lib/bb/cooker.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 05be9bef6..33452e7b9 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -1674,6 +1674,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
@@ -2063,6 +2064,7 @@ class CookerParser(object):
self.start()
self.haveshutdown = False
+ self.syncthread = None
def start(self):
self.results = self.load_cached()
@@ -2132,8 +2134,8 @@ class CookerParser(object):
c.sync()
sync = threading.Thread(target=sync_caches)
+ 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:
@@ -2147,6 +2149,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 mc, cache, filename, appends in self.fromcache:
cached, infos = cache.load(filename, appends)