diff mbox series

[bitbake-devel,2/2] wget.py: Combine urlopener exceptions

Message ID 20230309225221.273750-3-mark.hatle@kernel.crashing.org
State New
Headers show
Series Add fetch2 wget exception handler | expand

Commit Message

Mark Hatle March 9, 2023, 10:52 p.m. UTC
No reason to have three identical exception handles, refactor to catch any
of the exceptions with the same block of code.

Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
---
 bitbake/lib/bb/fetch2/wget.py | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index 927487a0b66..dc883176104 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -369,7 +369,7 @@  class Wget(FetchMethod):
 
                 with opener.open(r, timeout=30) as response:
                     pass
-            except urllib.error.URLError as e:
+            except (urllib.error.URLError, ConnectionResetError, TimeoutError) as e:
                 if try_again:
                     logger.debug2("checkstatus: trying again")
                     return self.checkstatus(fetch, ud, d, False)
@@ -377,22 +377,6 @@  class Wget(FetchMethod):
                     # debug for now to avoid spamming the logs in e.g. remote sstate searches
                     logger.debug2("checkstatus() urlopen failed: %s" % e)
                     return False
-            except ConnectionResetError as e:
-                if try_again:
-                    logger.debug2("checkstatus: trying again")
-                    return self.checkstatus(fetch, ud, d, False)
-                else:
-                    # debug for now to avoid spamming the logs in e.g. remote sstate searches
-                    logger.debug2("checkstatus() urlopen failed: %s" % e)
-                    return False
-            except TimeoutError as e:
-                if try_again:
-                    logger.debug2("checkstatus: trying again")
-                    return self.checkstatus(fetch, ud, d, False)
-                else:
-                    # debug for now to avoid spamming the logs in e.g. remote sstate searches
-                    logger.debug2("checkstatus() urlopen TimeoutError: %s" % e)
-                    return False
 
         return True