Skip to content

Commit

Permalink
handle connection errors during post as well (for hydrate)
Browse files Browse the repository at this point in the history
  • Loading branch information
edsu committed Jul 3, 2015
1 parent 891bd10 commit 20cb45a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion twarc.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,12 @@ def get(self, *args, **kwargs):

@rate_limit
def post(self, *args, **kwargs):
return self.client.post(*args, **kwargs)
try:
return self.client.post(*args, **kwargs)
except requests.exceptions.ConnectionError as e:
logging.error("caught connection error %s", e)
self._connect()
return self.post(*args, **kwargs)

def _connect(self):
logging.info("creating http session")
Expand Down

0 comments on commit 20cb45a

Please sign in to comment.