mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
refactor: create coroutines on demand
to avoid "coroutine was never awaited" warnings
This commit is contained in:
@@ -101,13 +101,11 @@ async def _fetch_ohlcv(
|
|||||||
|
|
||||||
connector = aiohttp.TCPConnector(limit=100)
|
connector = aiohttp.TCPConnector(limit=100)
|
||||||
async with aiohttp.ClientSession(connector=connector) as session:
|
async with aiohttp.ClientSession(connector=connector) as session:
|
||||||
coroutines = [
|
|
||||||
get_daily_ohlcv(asset_type, symbol, timeframe, date, session)
|
|
||||||
for date in date_range(start, end)
|
|
||||||
]
|
|
||||||
# the HTTP connections has been throttled by TCPConnector
|
# the HTTP connections has been throttled by TCPConnector
|
||||||
for batch in chunks(coroutines, 1000):
|
for dates in chunks(list(date_range(start, end)), 1000):
|
||||||
results = await asyncio.gather(*batch)
|
results = await asyncio.gather(
|
||||||
|
*(get_daily_ohlcv(asset_type, symbol, timeframe, date, session) for date in dates)
|
||||||
|
)
|
||||||
for result in results:
|
for result in results:
|
||||||
if isinstance(result, BaseException):
|
if isinstance(result, BaseException):
|
||||||
logger.warning(f"An exception raised: : {result}")
|
logger.warning(f"An exception raised: : {result}")
|
||||||
|
|||||||
Reference in New Issue
Block a user