File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -80,10 +80,9 @@ def run_recurring_tasks(database: str) -> list[RecurringTaskRun]:
8080 # This is necessary to ensure that old instances of the task processor,
8181 # which may still be running during deployment, do not remove tasks added by new instances.
8282 # Reference: https://github.com/Flagsmith/flagsmith/issues/2551
83- if (
84- timezone .now () - task .created_at
85- ) > UNREGISTERED_RECURRING_TASK_GRACE_PERIOD :
86- task .delete ()
83+ task_age = timezone .now () - task .created_at
84+ if task_age > UNREGISTERED_RECURRING_TASK_GRACE_PERIOD :
85+ task .delete (using = database )
8786 continue
8887
8988 if task .should_execute :
@@ -95,10 +94,13 @@ def run_recurring_tasks(database: str) -> list[RecurringTaskRun]:
9594
9695 # update all tasks that were not deleted
9796 to_update = [task for task in tasks if task .id ]
98- RecurringTask .objects .bulk_update (to_update , fields = ["is_locked" , "locked_at" ])
97+ RecurringTask .objects .using (database ).bulk_update (
98+ to_update ,
99+ fields = ["is_locked" , "locked_at" ],
100+ )
99101
100102 if task_runs :
101- RecurringTaskRun .objects .bulk_create (task_runs )
103+ RecurringTaskRun .objects .using ( database ). bulk_create (task_runs )
102104 logger .debug (f"Finished running { len (task_runs )} recurring task(s)" )
103105
104106 return task_runs
You can’t perform that action at this time.
0 commit comments