From 220a7e72379bdcee31305fc87f85bca13fea66d1 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Mon, 31 Jul 2023 22:27:26 +0700 Subject: [PATCH] Add submission to queue if judge disconnect --- judge/bridge/judge_handler.py | 32 +++++++++++++++++++++++--------- judge/bridge/judge_list.py | 1 + 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/judge/bridge/judge_handler.py b/judge/bridge/judge_handler.py index 5bfda23..2f13b8a 100644 --- a/judge/bridge/judge_handler.py +++ b/judge/bridge/judge_handler.py @@ -64,6 +64,7 @@ class JudgeHandler(ZlibPacketHandler): "handshake": self.on_handshake, } self._working = False + self._working_data = {} self._no_response_job = None self._problems = [] self.executors = {} @@ -110,16 +111,24 @@ class JudgeHandler(ZlibPacketHandler): self._make_json_log(action="disconnect", info="judge disconnected") ) if self._working: - 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", - ) + self.judges.judge( + self._working, + self._working_data["problem"], + self._working_data["language"], + self._working_data["source"], + None, + 0, ) + # 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): try: @@ -319,6 +328,11 @@ class JudgeHandler(ZlibPacketHandler): def submit(self, id, problem, language, source): data = self.get_related_submission_data(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.send( { diff --git a/judge/bridge/judge_list.py b/judge/bridge/judge_list.py index a670667..0552de4 100644 --- a/judge/bridge/judge_list.py +++ b/judge/bridge/judge_list.py @@ -89,6 +89,7 @@ class JudgeList(object): logger.info("Judge available after grading %d: %s", submission, judge.name) del self.submission_map[submission] judge._working = False + judge._working_data = {} self._handle_free_judge(judge) def abort(self, submission):