Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/undo_changes_trading_pair_fe…
Browse files Browse the repository at this point in the history
…tcher' into 0.38-altmarkets
  • Loading branch information
TheHolyRoger committed Apr 6, 2021
2 parents 5e59ec2 + 0618562 commit 0e20c23
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hummingbot/client/config/config_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
18 changes: 11 additions & 7 deletions hummingbot/core/utils/trading_pair_fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Expand All @@ -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] = []

0 comments on commit 0e20c23

Please sign in to comment.