From 6e6347e202aa478695a575ee60ce5a2214b1ff7e Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Sat, 19 Oct 2024 15:38:57 +0200 Subject: [PATCH] bugfixing --- app/cron_company_news.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/cron_company_news.py b/app/cron_company_news.py index 0747118..6fb73fe 100644 --- a/app/cron_company_news.py +++ b/app/cron_company_news.py @@ -71,10 +71,13 @@ async def process_chunk(session, chunk): data = await get_data(session, chunk) tasks = [] for symbol in chunk: - filtered_data = [item for item in data if item['symbol'] == symbol] - filtered_data = await filter_and_deduplicate(filtered_data) - if filtered_data: - tasks.append(save_json(symbol, filtered_data)) + try: + filtered_data = [item for item in data if item['symbol'] == symbol] + filtered_data = await filter_and_deduplicate(filtered_data) + if filtered_data: + tasks.append(save_json(symbol, filtered_data)) + except Exception as e: + print(e) if tasks: await asyncio.gather(*tasks) @@ -89,7 +92,7 @@ async def main(): total_symbols = stock_symbols + etf_symbols + crypto_symbols # Dynamically adjust chunk size - chunk_size = 15 # Adjust based on your needs + chunk_size = 10 # Adjust based on your needs chunks = [total_symbols[i:i + chunk_size] for i in range(0, len(total_symbols), chunk_size)] async with aiohttp.ClientSession() as session: