11import logging
2- from typing import Any , Literal
2+ from typing import Any , Literal , cast
33
44from redis import Redis
55from redis .exceptions import LockError
2121OLD_KEY = "flake_uploads:{}"
2222
2323
24- def get_redis_val (redis_client : Redis , repo_id : int ) -> tuple [ list [bytes ], bool ]:
25- commit_ids = redis_client .lpop (NEW_KEY .format (repo_id ), 10 )
24+ def get_redis_val (redis_client : Redis , repo_id : int ) -> list [bytes ]:
25+ commit_ids = cast ( list [ bytes ], redis_client .lpop (NEW_KEY .format (repo_id ), 10 ) )
2626 if commit_ids is None :
2727 commit_ids = []
2828
29- current_commit = False
30- with redis_client .pipeline () as pipe :
31- # can't use getdel because the value of the key is not a string
32- pipe .get (OLD_KEY .format (repo_id ))
33- pipe .delete (OLD_KEY .format (repo_id ))
34- commit_id = pipe .execute ()
35- if commit_id [0 ] is not None :
36- current_commit = True
37-
38- return commit_ids , current_commit
29+ return commit_ids
3930
4031
4132class ProcessFlakesTask (BaseCodecovTask , name = process_flakes_task_name ):
@@ -48,7 +39,6 @@ def run_impl(
4839 _db_session : Session ,
4940 * ,
5041 repo_id : int ,
51- commit_id : str ,
5242 impl_type : Literal ["old" , "new" , "both" ] = "old" ,
5343 ** kwargs : Any ,
5444 ):
@@ -75,10 +65,7 @@ def run_impl(
7565 The locking scheme is set up such that no upload will be unprocessed. Before queuing up the process flakes task the
7666 test results finisher and sync pulls tasks will set the flake_uploads key in redis for that repo.
7767 """
78- log .info (
79- "Received process flakes task" ,
80- extra = dict (repoid = repo_id , commit = commit_id ),
81- )
68+ log .info ("Received process flakes task" )
8269
8370 if impl_type == "new" or impl_type == "both" :
8471 process_flakes_for_repo (repo_id )
@@ -97,15 +84,12 @@ def run_impl(
9784 blocking_timeout = 3 ,
9885 ):
9986 while True :
100- commit_ids , current_commit = get_redis_val (redis_client , repo_id )
101- if not commit_ids and not current_commit :
87+ commit_shas = get_redis_val (redis_client , repo_id )
88+ if not commit_shas :
10289 break
10390
104- for commitid in commit_ids :
105- process_func (repo_id , commitid .decode ())
106-
107- if current_commit :
108- process_func (repo_id , commit_id )
91+ for commit_sha in commit_shas :
92+ process_func (repo_id , commit_sha .decode ())
10993
11094 except LockError :
11195 log .warning ("Unable to acquire process flakeslock for key %s." , lock_name )
0 commit comments