@@ -612,50 +612,63 @@ async def update_cache(
612612 redis : Redis [str ] = cast ("Redis[str]" , app .settings .get ("REDIS" ))
613613 prefix : str = app .settings .get ("REDIS_PREFIX" , NAME ).removesuffix ("-dev" )
614614 redis_available = EVENT_REDIS .is_set ()
615+ exceptions : list [Exception ] = []
615616
616617 if update_wrong_quotes :
617- await parse_list_of_quote_data (
618- wq_data := await make_api_request (
619- "wrongquotes" ,
620- entity_should_exist = True ,
621- request_timeout = 100 ,
622- ),
623- parse_wrong_quote ,
624- )
625- if wq_data and redis_available :
626- await redis .setex (
627- f"{ prefix } :cached-quote-data:wrongquotes" ,
628- 60 * 60 * 24 * 30 ,
629- json .dumps (wq_data , option = ORJSON_OPTIONS ),
618+ try :
619+ await parse_list_of_quote_data (
620+ wq_data := await make_api_request (
621+ "wrongquotes" ,
622+ entity_should_exist = True ,
623+ request_timeout = 100 ,
624+ ),
625+ parse_wrong_quote ,
630626 )
627+ if wq_data and redis_available :
628+ await redis .setex (
629+ f"{ prefix } :cached-quote-data:wrongquotes" ,
630+ 60 * 60 * 24 * 30 ,
631+ json .dumps (wq_data , option = ORJSON_OPTIONS ),
632+ )
633+ except Exception as err : # pylint: disable=broad-exception-caught
634+ exceptions .append (err )
631635
632636 if update_quotes :
633- await parse_list_of_quote_data (
634- quotes_data := await make_api_request (
635- "quotes" , entity_should_exist = True
636- ),
637- parse_quote ,
638- )
639- if quotes_data and redis_available :
640- await redis .setex (
641- f"{ prefix } :cached-quote-data:quotes" ,
642- 60 * 60 * 24 * 30 ,
643- json .dumps (quotes_data , option = ORJSON_OPTIONS ),
637+ try :
638+ await parse_list_of_quote_data (
639+ quotes_data := await make_api_request (
640+ "quotes" , entity_should_exist = True
641+ ),
642+ parse_quote ,
644643 )
644+ if quotes_data and redis_available :
645+ await redis .setex (
646+ f"{ prefix } :cached-quote-data:quotes" ,
647+ 60 * 60 * 24 * 30 ,
648+ json .dumps (quotes_data , option = ORJSON_OPTIONS ),
649+ )
650+ except Exception as err : # pylint: disable=broad-exception-caught
651+ exceptions .append (err )
645652
646653 if update_authors :
647- await parse_list_of_quote_data (
648- authors_data := await make_api_request (
649- "authors" , entity_should_exist = True
650- ),
651- parse_author ,
652- )
653- if authors_data and redis_available :
654- await redis .setex (
655- f"{ prefix } :cached-quote-data:authors" ,
656- 60 * 60 * 24 * 30 ,
657- json .dumps (authors_data , option = ORJSON_OPTIONS ),
654+ try :
655+ await parse_list_of_quote_data (
656+ authors_data := await make_api_request (
657+ "authors" , entity_should_exist = True
658+ ),
659+ parse_author ,
658660 )
661+ if authors_data and redis_available :
662+ await redis .setex (
663+ f"{ prefix } :cached-quote-data:authors" ,
664+ 60 * 60 * 24 * 30 ,
665+ json .dumps (authors_data , option = ORJSON_OPTIONS ),
666+ )
667+ except Exception as err : # pylint: disable=broad-exception-caught
668+ exceptions .append (err )
669+
670+ if exceptions :
671+ raise ExceptionGroup ("Cache could not be updated" , exceptions )
659672
660673 if (
661674 redis_available
0 commit comments