@@ -112,12 +112,22 @@ class EventWriter:
self.eventfile = eventfile
self.event_queue = []
+ def _open(self):
+ try:
+ return open(self.eventfile, "a")
+ except FileNotFoundError:
+ # setupEventLog() creates the folder, but will not re-create it if
+ # it is removed between two builds, with the resident process still
+ # in memory. Catch the resulting exception and re-create it.
+ bb.utils.mkdirhier(os.path.dirname(self.eventfile))
+ return open(self.eventfile, "a")
+
def write_variables(self):
- with open(self.eventfile, "a") as f:
+ with self._open() as f:
f.write("%s\n" % json.dumps({ "allvariables" : self.cooker.getAllKeysWithFlags(["doc", "func"])}))
def send(self, event):
- with open(self.eventfile, "a") as f:
+ with self._open() as f:
try:
str_event = codecs.encode(pickle.dumps(event), 'base64').decode('utf-8')
f.write("%s\n" % json.dumps({"class": event.__module__ + "." + event.__class__.__name__,
If the eventlog folder is removed while bitbake is still resident in memory, it will not be re-created on the next build and result in an exception while trying to write event logs. Catch this exception and create the folder as expected. [YOCTO #16492] Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> --- lib/bb/cooker.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) --- base-commit: f22df7e0e00be1f3c406138b8b7269d47ea491fe change-id: 20261113-mathieu-b16492-write-variables-4944e8e88bb0 Best regards,