Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- a/pgoapi/hash_server.py
- +++ b/pgoapi/hash_server.py
- @@ -38,29 +38,35 @@ class HashServer(HashEngine):
- 'Requests': [base64.b64encode(x.SerializeToString()).decode('ascii') for x in requestslist]
- }
- - # request hashes from hashing server
- - try:
- - response = self._session.post(self.endpoint, json=payload, headers=self.headers, timeout=30)
- - except requests.exceptions.Timeout:
- - raise HashingTimeoutException('Hashing request timed out.')
- - except requests.exceptions.ConnectionError as error:
- - raise HashingOfflineException(error)
- + for x in range (0, 5):
- + # request hashes from hashing server
- + try:
- + response = self._session.post(self.endpoint, json=payload, headers=self.headers, timeout=30)
- + except requests.exceptions.Timeout:
- + continue
- + # raise HashingTimeoutException('Hashing request timed out.')
- + except requests.exceptions.ConnectionError as error:
- + continue
- + # raise HashingOfflineException(error)
- +
- + if response.status_code == 400:
- + continue
- + # raise BadHashRequestException("400: Bad request, error: {}".format(response.text))
- + elif response.status_code == 403:
- + raise TempHashingBanException('Your IP was temporarily banned for sending too many requests with invalid keys')
- + elif response.status_code == 429:
- + raise HashingQuotaExceededException("429: Request limited, error: {}".format(response.text))
- + elif response.status_code in (502, 503, 504):
- + raise HashingOfflineException('{} Server Error'.format(response.status_code))
- + elif response.status_code != 200:
- + error = 'Unexpected HTTP server response - needs 200 got {c}. {t}'.format(
- + c=response.status_code, t=response.text)
- + raise UnexpectedHashResponseException(error)
- - if response.status_code == 400:
- - raise BadHashRequestException("400: Bad request, error: {}".format(response.text))
- - elif response.status_code == 403:
- - raise TempHashingBanException('Your IP was temporarily banned for sending too many requests with invalid keys')
- - elif response.status_code == 429:
- - raise HashingQuotaExceededException("429: Request limited, error: {}".format(response.text))
- - elif response.status_code in (502, 503, 504):
- - raise HashingOfflineException('{} Server Error'.format(response.status_code))
- - elif response.status_code != 200:
- - error = 'Unexpected HTTP server response - needs 200 got {c}. {t}'.format(
- - c=response.status_code, t=response.text)
- - raise UnexpectedHashResponseException(error)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement