diff mbox series

[yocto-autobuilder-helper] scripts/utils.py: add timeout check for tarball extraction

Message ID 20260606011918.61582-1-tim.orling@konsulko.com
State New
Headers show
Series [yocto-autobuilder-helper] scripts/utils.py: add timeout check for tarball extraction | expand

Commit Message

Tim Orling June 6, 2026, 1:19 a.m. UTC
The while True, try, except OSError: pass loop has a risk of
getting caught in an infinite loop. Add an overall timeout
to ensure we raise the underlying OSError after we have tried
for 300 seconds/5 minutes.

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 scripts/utils.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/scripts/utils.py b/scripts/utils.py
index a4dd12e..4aa4468 100644
--- a/scripts/utils.py
+++ b/scripts/utils.py
@@ -506,6 +506,7 @@  def setup_tools_tarball(ourconfig, btdir, bttarball, name="buildtools"):
         # previous build.  tarball_updated is set to True whenever the cached
         # download is replaced, which triggers removal of the stale btdir.
         tarball_updated = False
+        tarball_timeout = time.monotonic() + 300  # 5 min, tune as needed
         while True:
             try:
                 with open(btlock, 'a+') as lf:
@@ -548,7 +549,10 @@  def setup_tools_tarball(ourconfig, btdir, bttarball, name="buildtools"):
                 break
             except OSError:
                 # We raced with someone else, try again
-                pass
+                if time.monotonic() > tarball_timeout:
+                    raise
+                time.sleep(1)
+
         # If the underlying tarball changed, remove any stale extraction
         # directory so it is re-extracted below.
         if tarball_updated and os.path.exists(btdir):