@@ -502,17 +502,10 @@ def search_jobs_not_done(self):
502
502
new_submission_ids_to_check = \
503
503
[x .id for x in contest .get_submissions ()
504
504
if (not x .compiled () and x .compilation_tries <
505
- EvaluationService .MAX_COMPILATION_TRIES and
506
- (EvaluationService .JOB_TYPE_COMPILATION , x .id ) not in
507
- self .queue and
508
- (EvaluationService .JOB_TYPE_COMPILATION , x .id ) not in
509
- self .pool )
510
- or (not x .evaluated () and x .evaluation_tries <
511
- EvaluationService .MAX_EVALUATION_TRIES and
512
- (EvaluationService .JOB_TYPE_EVALUATION , x .id ) not in
513
- self .queue and
514
- (EvaluationService .JOB_TYPE_EVALUATION , x .id )
515
- not in self .pool )]
505
+ EvaluationService .MAX_COMPILATION_TRIES )
506
+ or (x .compilation_outcome == "ok" and
507
+ not x .evaluated () and x .evaluation_tries <
508
+ EvaluationService .MAX_EVALUATION_TRIES )]
516
509
517
510
new = len (new_submission_ids_to_check )
518
511
old = len (self .submission_ids_to_check )
@@ -661,7 +654,7 @@ def check_workers_timeout(self):
661
654
for priority , timestamp , job in lost_jobs :
662
655
logger .info ("Job %s for submission %s put again in the queue "
663
656
"because of timeout worker." % (job [0 ], job [1 ]))
664
- self .queue . push (job , priority , timestamp )
657
+ self .push_in_queue (job , priority , timestamp )
665
658
return True
666
659
667
660
def check_workers_connection (self ):
@@ -673,9 +666,24 @@ def check_workers_connection(self):
673
666
for priority , timestamp , job in lost_jobs :
674
667
logger .info ("Job %s for submission %s put again in the queue "
675
668
"because of disconnected worker." % (job [0 ], job [1 ]))
676
- self .queue . push (job , priority , timestamp )
669
+ self .push_in_queue (job , priority , timestamp )
677
670
return True
678
671
672
+ def push_in_queue (self , job , priority , timestamp ):
673
+ """Push a job in the job queue if the job is not already in
674
+ the queue or assigned to a worker.
675
+
676
+ job (job): a couple (job_type, submission_id) to push.
677
+
678
+ return (bool): True if pushed, False if not.
679
+
680
+ """
681
+ if job in self .queue or job in self .pool :
682
+ return False
683
+ else :
684
+ self .queue .push (job , priority , timestamp )
685
+ return True
686
+
679
687
@rpc_callback
680
688
def action_finished (self , data , plus , error = None ):
681
689
"""Callback from a worker, to signal that is finished some
@@ -765,8 +773,8 @@ def compilation_ended(self, submission_id,
765
773
priority = EvaluationService .JOB_PRIORITY_LOW
766
774
if tokened :
767
775
priority = EvaluationService .JOB_PRIORITY_MEDIUM
768
- self .queue . push ((EvaluationService .JOB_TYPE_EVALUATION ,
769
- submission_id ), priority , timestamp )
776
+ self .push_in_queue ((EvaluationService .JOB_TYPE_EVALUATION ,
777
+ submission_id ), priority , timestamp )
770
778
# If instead submission failed compilation, we don't evaluate.
771
779
elif compilation_outcome == "fail" :
772
780
logger .info ("Submission %s did not compile. Not going "
@@ -780,10 +788,10 @@ def compilation_ended(self, submission_id,
780
788
else :
781
789
# Note: lower priority (MEDIUM instead of HIGH) for
782
790
# compilation that are probably failing again.
783
- self .queue . push ((EvaluationService .JOB_TYPE_COMPILATION ,
784
- submission_id ),
785
- EvaluationService .JOB_PRIORITY_MEDIUM ,
786
- timestamp )
791
+ self .push_in_queue ((EvaluationService .JOB_TYPE_COMPILATION ,
792
+ submission_id ),
793
+ EvaluationService .JOB_PRIORITY_MEDIUM ,
794
+ timestamp )
787
795
# Otherwise, error.
788
796
else :
789
797
logger .error ("Compilation outcome %r not recognized." %
@@ -813,8 +821,8 @@ def evaluation_ended(self, submission_id,
813
821
priority = EvaluationService .JOB_PRIORITY_LOW
814
822
if tokened :
815
823
priority = EvaluationService .JOB_PRIORITY_MEDIUM
816
- self .queue . push ((EvaluationService .JOB_TYPE_EVALUATION ,
817
- submission_id ), priority , timestamp )
824
+ self .push_in_queue ((EvaluationService .JOB_TYPE_EVALUATION ,
825
+ submission_id ), priority , timestamp )
818
826
else :
819
827
logger .error ("Maximum tries reached for the "
820
828
"evaluation of submission %s. I will "
@@ -845,10 +853,10 @@ def new_submission(self, submission_id):
845
853
# If not compiled, I compile. Note that we give here a
846
854
# chance for submissions that already have too many
847
855
# compilation tries.
848
- self .queue . push ((EvaluationService .JOB_TYPE_COMPILATION ,
849
- submission_id ),
850
- EvaluationService .JOB_PRIORITY_HIGH ,
851
- timestamp )
856
+ self .push_in_queue ((EvaluationService .JOB_TYPE_COMPILATION ,
857
+ submission_id ),
858
+ EvaluationService .JOB_PRIORITY_HIGH ,
859
+ timestamp )
852
860
else :
853
861
if not evaluated :
854
862
self .compilation_ended (submission_id ,
0 commit comments