[yocto-autobuilder-helper][PATCH] scripts/utils.py: add timeout check for tarball extraction
Tim Orling <[email protected]>
| Newsgroups | org.yoctoproject.lists.yocto-patches |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- scripts/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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): -- 2.54.0