Skip to content

Commit

Permalink
sync: use backoff/retry on all kinds of IO errors
Browse files Browse the repository at this point in the history
  • Loading branch information
d70-t committed Jun 20, 2023
1 parent a40d5bc commit fc3b145
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ipfsspec/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ def get(self, path):
logger.debug("get %s via %s", path, self.url)
try:
res = self.session.get(self.url + "/ipfs/" + path)
except requests.ConnectionError as e:
logger.debug("Connection Error: %s", e)
except IOError as e:
logger.debug("IOError: %s", e)
self._backoff()
return None
# this is from https://blog.petrzemek.net/2018/04/22/on-incomplete-http-reads-and-the-requests-library-in-python/
Expand All @@ -59,8 +59,8 @@ def head(self, path, headers=None):
logger.debug("head %s via %s", path, self.url, headers=headers or {})
try:
res = self.session.get(self.url + "/ipfs/" + path)
except requests.ConnectionError as e:
logger.debug("Connection Error: %s", e)
except IOError as e:
logger.debug("IOError: %s", e)
self._backoff()
return None
if res.status_code == 429: # too many requests
Expand All @@ -75,7 +75,7 @@ def apipost(self, call, **kwargs):
logger.debug("post %s via %s", call, self.url)
try:
res = self.session.post(self.url + "/api/v0/" + call, params=kwargs)
except requests.ConnectionError:
except IOError:
self._backoff()
return None
if res.status_code == 429: # too many requests
Expand Down Expand Up @@ -107,7 +107,7 @@ def _init_state(self):
self.state = "online"
else:
self.state = "offline"
except requests.ConnectionError:
except IOError:
self.state = "offline"

def get_state(self):
Expand Down

0 comments on commit fc3b145

Please sign in to comment.