diff --git a/hummingbot/connector/exchange/altmarkets/altmarkets_exchange.pyx b/hummingbot/connector/exchange/altmarkets/altmarkets_exchange.pyx index 345093e9e5..b9a27460b9 100644 --- a/hummingbot/connector/exchange/altmarkets/altmarkets_exchange.pyx +++ b/hummingbot/connector/exchange/altmarkets/altmarkets_exchange.pyx @@ -287,7 +287,7 @@ cdef class AltmarketsExchange(ExchangeBase): timeout=100 ) - parsed_response, request_errors = None, False + http_status, parsed_response, request_errors = None, None, False try: async with response_coro as response: try: @@ -302,20 +302,21 @@ cdef class AltmarketsExchange(ExchangeBase): pass if response.status not in [200, 201] or parsed_response is None: request_errors = True + http_status = response.status except Exception: request_errors = True if request_errors or parsed_response is None: if try_count < 4: try_count += 1 time_sleep = retry_sleep_time(try_count) - print(f"Error fetching data from {url}. HTTP status is {response.status}. " + print(f"Error fetching data from {url}. HTTP status is {http_status}. " f"Retrying in {time_sleep:.1f}s.") await asyncio.sleep(time_sleep) return await self._api_request(method=method, path_url=path_url, params=params, data=data, is_auth_required = is_auth_required, try_count=try_count, request_weight=request_weight) else: - print(f"Error fetching data from {url}. HTTP status is {response.status}. " + print(f"Error fetching data from {url}. HTTP status is {http_status}. " f"Final msg: {parsed_response}.") raise AltmarketsAPIError({"error": parsed_response}) return parsed_response diff --git a/hummingbot/connector/exchange/altmarkets/altmarkets_utils.py b/hummingbot/connector/exchange/altmarkets/altmarkets_utils.py index 7f26f53500..9090a5f0c1 100644 --- a/hummingbot/connector/exchange/altmarkets/altmarkets_utils.py +++ b/hummingbot/connector/exchange/altmarkets/altmarkets_utils.py @@ -68,7 +68,7 @@ async def generic_api_request(method, response_coro = http_client.request( method=method.upper(), url=url, headers=headers, params=params, timeout=Constants.API_CALL_TIMEOUT ) - parsed_response, request_errors = None, False + http_status, parsed_response, request_errors = None, None, False try: async with response_coro as response: try: @@ -83,19 +83,20 @@ async def generic_api_request(method, pass if response.status not in [200, 201] or parsed_response is None: request_errors = True + http_status = response.status except Exception: request_errors = True if request_errors or parsed_response is None: if try_count < 4: try_count += 1 time_sleep = retry_sleep_time(try_count) - print(f"Error fetching data from {url}. HTTP status is {response.status}. " + print(f"Error fetching data from {url}. HTTP status is {http_status}. " f"Retrying in {time_sleep:.1f}s.") await asyncio.sleep(time_sleep) return await generic_api_request(method=method, path_url=path_url, params=params, client=client, try_count=try_count) else: - print(f"Error fetching data from {url}. HTTP status is {response.status}. " + print(f"Error fetching data from {url}. HTTP status is {http_status}. " f"Final msg: {parsed_response}.") raise AltmarketsAPIError({"error": parsed_response}) return parsed_response