Exemplo n.º 1
0
class JudgeServer(get_preferred_engine()):
    def __init__(self, *args, **kwargs):
        super(JudgeServer, self).__init__(*args, **kwargs)
        reset_judges()
        Submission.objects.filter(
            status__in=Submission.IN_PROGRESS_GRADING_STATUS).update(
                status='IE', result='IE')
        self.judges = JudgeList()
        self.ping_judge_thread = threading.Thread(target=self.ping_judge,
                                                  args=())
        self.ping_judge_thread.daemon = True
        self.ping_judge_thread.start()

    def on_shutdown(self):
        super(JudgeServer, self).on_shutdown()
        reset_judges()

    def ping_judge(self):
        try:
            while True:
                for judge in self.judges:
                    judge.ping()
                time.sleep(10)
        except Exception:
            logger.exception('Ping error')
            raise
Exemplo n.º 2
0
class JudgeServer(get_preferred_engine()):
    def __init__(self, *args, **kwargs):
        super(JudgeServer, self).__init__(*args, **kwargs)
        self.judges = JudgeList()
        self.ping_judge_thread = threading.Thread(target=self.ping_judge,
                                                  args=())
        self.ping_judge_thread.daemon = True
        self.ping_judge_thread.start()

    def on_shutdown(self):
        super(JudgeServer, self).on_shutdown()

    def ping_judge(self):
        try:
            while True:
                for judge in self.judges:
                    judge.ping()
                time.sleep(10)
        except:
            raise
class DjangoServer(get_preferred_engine()):
    def __init__(self, judges, *args, **kwargs):
        super(DjangoServer, self).__init__(*args, **kwargs)
        self.judges = judges