Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyene committed Dec 25, 2023
1 parent 0bda201 commit c09536c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dmoj/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ def log_internal_error(self, exc: Optional[BaseException] = None, message: Optio
class JudgeWorker:
def __init__(self, submission: Submission) -> None:
self.submission = submission
self._aborted = True
self._sent_sigkill_to_worker_process = False
# FIXME(tbrindus): marked Any pending grader cleanups.
self.grader: Any = None
Expand All @@ -337,9 +338,13 @@ def communicate(self) -> Generator[Tuple[IPC, tuple], None, None]:
self.worker_process.kill()
raise
except EOFError:
if self._sent_sigkill_to_worker_process:
if self._aborted:
# Expected, the pipe is broken.
pass
elif self._sent_sigkill_to_worker_process:
raise TimeoutError('worker did not exit in %d seconds, so it was killed' % IPC_TIMEOUT)
raise
else:
raise
except Exception:
logger.error('Failed to read IPC message from worker!')
raise
Expand All @@ -365,6 +370,7 @@ def wait_with_timeout(self) -> None:

def abort_grading__kill_worker(self) -> None:
if self.worker_process and self.worker_process.is_alive():
self._aborted = True
self._sent_sigkill_to_worker_process = True
self.worker_process.kill()
self.worker_process.join(timeout=1)
Expand Down

0 comments on commit c09536c

Please sign in to comment.