diff --git a/hummingbot/client/config/config_helpers.py b/hummingbot/client/config/config_helpers.py index 2f8b491c75..8bc0b2ebcc 100644 --- a/hummingbot/client/config/config_helpers.py +++ b/hummingbot/client/config/config_helpers.py @@ -171,7 +171,7 @@ def get_erc20_token_addresses() -> Dict[str, List]: address_file_path = TOKEN_ADDRESSES_FILE_PATH token_list = {} - resp = requests.get(token_list_url, timeout=3) + resp = requests.get(token_list_url, timeout=1) decoded_resp = resp.json() for token in decoded_resp["tokens"]: diff --git a/hummingbot/core/utils/trading_pair_fetcher.py b/hummingbot/core/utils/trading_pair_fetcher.py index 81078f8bb2..ea07080568 100644 --- a/hummingbot/core/utils/trading_pair_fetcher.py +++ b/hummingbot/core/utils/trading_pair_fetcher.py @@ -4,11 +4,11 @@ Any, Optional, ) -from hummingbot.core.utils.async_utils import safe_gather from hummingbot.logger import HummingbotLogger from hummingbot.client.settings import CONNECTOR_SETTINGS, ConnectorType import logging import asyncio +import requests from .async_utils import safe_ensure_future @@ -35,8 +35,6 @@ def __init__(self): safe_ensure_future(self.fetch_all()) async def fetch_all(self): - tasks = [] - fetched_connectors = [] for conn_setting in CONNECTOR_SETTINGS.values(): module_name = f"{conn_setting.base_name()}_connector" if conn_setting.type is ConnectorType.Connector \ else f"{conn_setting.base_name()}_api_order_book_data_source" @@ -48,9 +46,15 @@ async def fetch_all(self): module = getattr(importlib.import_module(module_path), class_name) args = {} args = conn_setting.add_domain_parameter(args) - tasks.append(asyncio.wait_for(asyncio.shield(module.fetch_trading_pairs(**args)), timeout=3)) - fetched_connectors.append(conn_setting.name) + safe_ensure_future(self.call_fetch_pairs(module.fetch_trading_pairs(**args), conn_setting.name)) - results = await safe_gather(*tasks, return_exceptions=True) - self.trading_pairs = dict(zip(fetched_connectors, results)) self.ready = True + + async def call_fetch_pairs(self, fetch_fn, exchange_name): + # In case trading pair fetching returned timeout, using empty list + try: + self.trading_pairs[exchange_name] = await fetch_fn + except (asyncio.TimeoutError, asyncio.CancelledError, requests.exceptions.RequestException): + self.logger().error(f"Connector {exchange_name} failed to retrieve its trading pairs. " + f"Trading pairs autocompletion won't work.") + self.trading_pairs[exchange_name] = []