diff --git a/hummingbot/core/utils/trading_pair_fetcher.py b/hummingbot/core/utils/trading_pair_fetcher.py index ae79aefe9a..1da79fa514 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,6 +35,8 @@ 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" @@ -46,8 +48,8 @@ async def fetch_all(self): module = getattr(importlib.import_module(module_path), class_name) args = {} args = conn_setting.add_domain_parameter(args) - safe_ensure_future(self.call_fetch_pairs(module.fetch_trading_pairs(**args), conn_setting.name)) - + tasks.append(asyncio.wait_for(asyncio.shield(module.fetch_trading_pairs(**args)), timeout=3)) + fetched_connectors.append(conn_setting.name) results = await safe_gather(*tasks, return_exceptions=True) self.trading_pairs = dict(zip(fetched_connectors, results)) @@ -55,5 +57,4 @@ async def fetch_all(self): for connector, result in self.trading_pairs.items(): if isinstance(result, asyncio.TimeoutError): self.trading_pairs[connector] = [] - - self.ready = True \ No newline at end of file + self.ready = True