diff mbox series

tinfoil: Disable data tracking also when the operation fails

Message ID 20261123203608.867455-1-stondo@gmail.com
State New
Headers show
Series tinfoil: Disable data tracking also when the operation fails | expand

Commit Message

Stefano Tondo Nov. 23, 2026, 8:36 p.m. UTC
From: Stefano Tondo <stefano.tondo.ext@siemens.com>

_data_tracked_if_enabled() enables data tracking before the operation
and disables it after the operation. If the operation raises an
exception, the second step does not run and tracking stays enabled in
the server for the rest of the tinfoil session.

Disable tracking in a finally block.

Signed-off-by: Stefano Tondo <stefano.tondo.ext@siemens.com>
---
 lib/bb/tinfoil.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/tinfoil.py b/lib/bb/tinfoil.py
index 9b9925e51..4fd2a9af8 100644
--- a/lib/bb/tinfoil.py
+++ b/lib/bb/tinfoil.py
@@ -789,10 +789,11 @@  class Tinfoil:
             self.run_command('enableDataTracking')
 
         # Here goes the operation with the optional data tracking
-        yield
-
-        if self.tracking:
-            self.run_command('disableDataTracking')
+        try:
+            yield
+        finally:
+            if self.tracking:
+                self.run_command('disableDataTracking')
 
     def finalizeData(self):
         """