@@ -25,14 +25,14 @@ class Config(BaseSettings):
2525 cacher_sentry_traces_sample_rate : float = 0.2
2626
2727
28- async def load_redis_cache (redis , cache_key ) :
28+ async def load_redis_cache (redis : aioredis . Redis , cache_key : str ) -> dict :
2929 value = await redis .get (cache_key )
3030 if not value :
3131 return {}
3232 return json .loads (value )
3333
3434
35- async def save_redis_cache (redis , cache_key , cache ):
35+ async def save_redis_cache (redis : aioredis . Redis , cache_key : str , cache : dict ):
3636 await redis .set (cache_key , json .dumps (cache ))
3737
3838
@@ -49,7 +49,13 @@ def setup_logger():
4949 return logger
5050
5151
52- async def run (config , logger , redis_client , gitea_client , organization ):
52+ async def run (
53+ config : Config ,
54+ logger : logging .Logger ,
55+ redis_client : aioredis .Redis ,
56+ gitea_client : GiteaClient ,
57+ organization : str ,
58+ ):
5359 cache = await load_redis_cache (
5460 redis_client , config .git_cache_keys [organization ]
5561 )
@@ -114,15 +120,19 @@ async def main():
114120 wait = 600
115121 while True :
116122 logger .info ('Checking cache for updates' )
117- await asyncio .gather (
118- # projects git data live in these gitea orgs
119- run (config , logger , redis_client , gitea_client , 'rpms' ),
120- run (config , logger , redis_client , gitea_client , 'modules' ),
121- # almalinux modified packages live in autopatch gitea org
122- run (config , logger , redis_client , gitea_client , 'autopatch' ),
123- )
123+ await asyncio .gather (* (
124+ run (config , logger , redis_client , gitea_client , organization )
125+ for organization in (
126+ # projects git data live in these gitea orgs
127+ 'rpms' ,
128+ 'modules' ,
129+ # almalinux modified packages live in autopatch gitea org
130+ 'autopatch' ,
131+ )
132+ ))
124133 logger .info (
125- 'Cache has been updated, waiting for %d secs for next update' % wait
134+ 'Cache has been updated, waiting for %d secs for next update' ,
135+ wait ,
126136 )
127137 await asyncio .sleep (wait )
128138
0 commit comments