@@ -194,15 +194,21 @@ def _send_to_compute_worker(submission, is_scoring):
194194 time_padding = 60 * 20 # 20 minutes
195195 time_limit = submission .phase .execution_time_limit + time_padding
196196
197+ if submission .phase .competition .queue : # if the competition is running on a custom queue, not the default queue
198+ submission .queue_name = submission .phase .competition .queue .name or ''
199+ run_args ['execution_time_limit' ] = submission .phase .execution_time_limit # use the competition time limit
200+ submission .save (update_fields = ["queue_name" ])
201+ if submission .status == Submission .SUBMITTING :
202+ # Don't want to mark an already-prepared submission as "submitted" again, so
203+ # only do this if we were previously "SUBMITTING"
204+ submission .status = Submission .SUBMITTED
205+ submission .save (update_fields = ["status" ])
206+
197207 def _enqueue_after_commit ():
198208 # priority of scoring tasks is higher, we don't want to wait around for
199209 # many submissions to be scored while we're waiting for results
200210 priority = 10 if is_scoring else 0
201-
202- if submission .phase .competition .queue : # if the competition is running on a custom queue, not the default queue
203- submission .queue_name = submission .phase .competition .queue .name or ''
204- run_args ['execution_time_limit' ] = submission .phase .execution_time_limit # use the competition time limit
205- submission .save (update_fields = ["queue_name" ])
211+ if submission .phase .competition .queue :
206212 celery_app = app_or_default ()
207213 with celery_app .connection () as new_connection :
208214 new_connection .virtual_host = str (submission .phase .competition .queue .vhost )
@@ -222,15 +228,8 @@ def _enqueue_after_commit():
222228 soft_time_limit = time_limit ,
223229 priority = priority ,
224230 )
225-
226231 submission .celery_task_id = task .id
227-
228- if submission .status == Submission .SUBMITTING :
229- # Don't want to mark an already-prepared submission as "submitted" again, so
230- # only do this if we were previously "SUBMITTING"
231- submission .status = Submission .SUBMITTED
232-
233- submission .save (update_fields = ["celery_task_id" , "status" ])
232+ submission .save (update_fields = ["celery_task_id" ])
234233
235234 transaction .on_commit (_enqueue_after_commit )
236235
0 commit comments