All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cooker: create missing eventlog directory
@ 2026-11-13 14:34 Mathieu Dubois-Briand
  2026-11-14 18:55 ` Babanpreet Singh
  0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Dubois-Briand @ 2026-11-13 14:34 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Thomas Petazzoni, Mathieu Dubois-Briand

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(-)

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 8a422e50621a..5b8b35c133bd 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -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__,

---
base-commit: f22df7e0e00be1f3c406138b8b7269d47ea491fe
change-id: 20261113-mathieu-b16492-write-variables-4944e8e88bb0

Best regards,
-- 
Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-14 18:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 14:34 [PATCH] cooker: create missing eventlog directory Mathieu Dubois-Briand
2026-11-14 18:55 ` Babanpreet Singh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.