Skip to content

Commit 362d7b3

Browse files
fix: add schedule followup (#775)
* fix: add schedule followup * fix: class and lint
1 parent ec58642 commit 362d7b3

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

apps/worker/tasks/upload_finisher.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
from helpers.save_commit_error import save_commit_error
2020
from services.comparison import get_or_create_comparison
2121
from services.lock_manager import LockManager, LockRetry, LockType
22+
from services.processing.finisher_gate import (
23+
FINISHER_GATE_TTL_SECONDS,
24+
refresh_finisher_gate_ttl,
25+
)
2226
from services.processing.intermediate import (
2327
cleanup_intermediate_reports,
2428
intermediate_report_key,
@@ -53,8 +57,9 @@
5357

5458
log = logging.getLogger(__name__)
5559

56-
FINISHER_BLOCKING_TIMEOUT_SECONDS = 30
5760
FINISHER_BASE_RETRY_COUNTDOWN_SECONDS = 10
61+
FINISHER_BLOCKING_TIMEOUT_SECONDS = 30
62+
FINISHER_SWEEP_DELAY = 30
5863

5964
UPLOAD_FINISHER_ALREADY_COMPLETED_COUNTER = Counter(
6065
"upload_finisher_already_completed",
@@ -70,6 +75,12 @@ class ShouldCallNotifyResult(Enum):
7075
NOTIFY = "notify"
7176

7277

78+
class UploadFinisherFollowUpTaskType(Enum):
79+
SWEEP = "sweep"
80+
WATCHDOG = "watchdog"
81+
CONTINUATION = "continuation"
82+
83+
7384
class UploadFinisherTask(BaseCodecovTask, name=upload_finisher_task_name):
7485
"""This is the third task of the series of tasks designed to process an `upload` made
7586
by the user
@@ -225,6 +236,29 @@ def _reconstruct_processing_results(
225236

226237
return processing_results
227238

239+
def _schedule_followup(
240+
self,
241+
repoid: int,
242+
commitid: str,
243+
commit_yaml: UserYaml,
244+
followup_type: UploadFinisherFollowUpTaskType,
245+
):
246+
refresh_finisher_gate_ttl(repoid, commitid)
247+
default_countdowns = {
248+
UploadFinisherFollowUpTaskType.SWEEP: FINISHER_SWEEP_DELAY,
249+
UploadFinisherFollowUpTaskType.CONTINUATION: 0,
250+
UploadFinisherFollowUpTaskType.WATCHDOG: FINISHER_GATE_TTL_SECONDS,
251+
}
252+
self.app.tasks[upload_finisher_task_name].apply_async(
253+
kwargs={
254+
"commit_yaml": commit_yaml.to_dict(),
255+
"commitid": commitid,
256+
"repoid": repoid,
257+
"trigger": followup_type.value,
258+
},
259+
countdown=default_countdowns[followup_type],
260+
)
261+
228262
def run_impl(
229263
self,
230264
db_session,

0 commit comments

Comments
 (0)