Skip to content

Commit

Permalink
Ability to stop sweeper for some rounds
Browse files Browse the repository at this point in the history
  • Loading branch information
stefano-maggiolo authored and mkrima committed Jul 29, 2017
1 parent 5c403fa commit 5f9fc55
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions cms/service/QueueService.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,9 @@ def __init__(self, shard, contest_id=None):
self.connect_to(ServiceCoord("EvaluationService", i))
for i in range(get_service_shards("EvaluationService"))]

# How many calls to the sweeper will be ignored. Used to
# temporarily disable it in case of invalidate.
self.avoid_next_sweepers = 0
self.add_executor(EvaluationExecutor(self))
self.start_sweeper(117.0)

Expand All @@ -347,6 +350,11 @@ def _missing_operations(self):
the queue.
"""
# Shortcircuit the sweeper if instructed to do so by the rest of QS.
if self.avoid_next_sweepers > 0:
self.avoid_next_sweepers -= 1
return 0

counter = 0
with SessionGen() as session:

Expand Down Expand Up @@ -566,6 +574,11 @@ def invalidate_submission(self,
"""
logger.info("Invalidation request received.")

# Avoid running the sweeper for the next 10-ish minutes, to
# avoid race conditions between invalidate's requeuing of
# submissions and the sweeper's.
self.avoid_next_sweepers = 5

# Validate arguments
# TODO Check that all these objects belong to this contest.
if level not in ("compilation", "evaluation"):
Expand Down

0 comments on commit 5f9fc55

Please sign in to comment.