Skip to contentSkip to conversation

fetch2/wget: Avoid crashing when connection drops mid checkstatus

PATCH New Alejandro Hernandez Samaniego 1 participant 1 message Feb 19, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2/wget: Avoid crashing when connection drops mid checkstatus

If an exception is raised when running host python code, the fetcher immediately crashes, this might be temporary depending on the servers reliability.

Catch the exception when the connection was reset and try once again to fetch the data.

File: '/usr/lib/python3.8/socket.py', lineno: 669, function: readinto
0665: if self._timeout_occurred:
0666: raise OSError("cannot read from timed out object")
0667: while True:
0668: try:
*** 0669: return self._sock.recv_into(b)
0670: except timeout:
0671: self._timeout_occurred = True
0672: raise
0673: except error as e:
Exception: ConnectionResetError: [Errno 104] Connection reset by peer

---
 lib/bb/fetch2/wget.py | 8 ++++++++
 1 file changed, 8 insertions(+)
lib/bb/fetch2/wget.py +8 -0
index 78a49676..6d82f3af 100644
@@ -332,6 +332,14 @@ 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
         return True
 
     def _parse_path(self, regex, s):
Signature · 1 line
2.25.1