Skip to content

Commit

Permalink
chore: retry connection reset errors for mixpanel
Browse files Browse the repository at this point in the history
  • Loading branch information
am6010 committed Jun 11, 2024
1 parent fbbe609 commit c82ad42
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,17 @@ def backoff_time(self, response: requests.Response) -> float:
return float(retry_after)

self.retries += 1
return 2**self.retries * 60
return min(2**self.retries * 60, 32 * 60)

def should_retry(self, response: requests.Response) -> bool:
if response.status_code == 402:
self.logger.warning(f"Unable to perform a request. Payment Required: {response.json()['error']}")
return False
try:
response.json()
except ConnectionResetError:
self.logger.warning(f"Got a connection reset error. Retrying request.")
return True
return super().should_retry(response)

def get_stream_params(self) -> Mapping[str, Any]:
Expand Down

0 comments on commit c82ad42

Please sign in to comment.