Add submission to queue if judge disconnect

This commit is contained in:
cuom1999 2023-07-31 22:27:26 +07:00
parent 1e88e73082
commit 220a7e7237
2 changed files with 24 additions and 9 deletions

View file

@ -64,6 +64,7 @@ class JudgeHandler(ZlibPacketHandler):
"handshake": self.on_handshake, "handshake": self.on_handshake,
} }
self._working = False self._working = False
self._working_data = {}
self._no_response_job = None self._no_response_job = None
self._problems = [] self._problems = []
self.executors = {} self.executors = {}
@ -110,16 +111,24 @@ class JudgeHandler(ZlibPacketHandler):
self._make_json_log(action="disconnect", info="judge disconnected") self._make_json_log(action="disconnect", info="judge disconnected")
) )
if self._working: if self._working:
Submission.objects.filter(id=self._working).update( self.judges.judge(
status="IE", result="IE", error="" self._working,
) self._working_data["problem"],
json_log.error( self._working_data["language"],
self._make_json_log( self._working_data["source"],
sub=self._working, None,
action="close", 0,
info="IE due to shutdown on grading",
)
) )
# Submission.objects.filter(id=self._working).update(
# status="IE", result="IE", error=""
# )
# json_log.error(
# self._make_json_log(
# sub=self._working,
# action="close",
# info="IE due to shutdown on grading",
# )
# )
def _authenticate(self, id, key): def _authenticate(self, id, key):
try: try:
@ -319,6 +328,11 @@ class JudgeHandler(ZlibPacketHandler):
def submit(self, id, problem, language, source): def submit(self, id, problem, language, source):
data = self.get_related_submission_data(id) data = self.get_related_submission_data(id)
self._working = id self._working = id
self._working_data = {
"problem": problem,
"language": language,
"source": source,
}
self._no_response_job = threading.Timer(20, self._kill_if_no_response) self._no_response_job = threading.Timer(20, self._kill_if_no_response)
self.send( self.send(
{ {

View file

@ -89,6 +89,7 @@ class JudgeList(object):
logger.info("Judge available after grading %d: %s", submission, judge.name) logger.info("Judge available after grading %d: %s", submission, judge.name)
del self.submission_map[submission] del self.submission_map[submission]
judge._working = False judge._working = False
judge._working_data = {}
self._handle_free_judge(judge) self._handle_free_judge(judge)
def abort(self, submission): def abort(self, submission):