upgrade to python3;add some validator examples

This commit is contained in:
2025-10-11 12:33:24 +08:00
parent 65632f0e60
commit 487c041148
25 changed files with 1492 additions and 317 deletions

View File

@@ -1,11 +1,17 @@
import logging, os, thread, threading, time, Queue
import logging
import _thread
import threading
import time
import queue
from engineconfig import getConfig
class JudgeEngine:
def __init__(self):
self.quit_event = threading.Event()
self.test_queue = Queue.Queue()
self.test_queue = queue.Queue()
self.config = getConfig()
self.quit_event.clear()
@@ -14,11 +20,11 @@ class JudgeEngine:
def run(self):
# one thread mode is good for debugging
if self.config.test_threads == 1:
thread.start_new_thread(self.transport, ())
_thread.start_new_thread(self.transport, ())
self.test()
else:
for i in range(self.config.test_threads):
thread.start_new_thread(self.test, ())
_thread.start_new_thread(self.test, ())
self.transport()
for ds in self.config.datasources:
@@ -30,7 +36,7 @@ class JudgeEngine:
total = 0
while not self.quit_event.isSet():
self.logger.info(
"%d submit in test queue, %d processed" % \
"%d submit in test queue, %d processed" %
(self.test_queue.qsize(), total))
c = 16 - self.test_queue.qsize()
if c > 0:
@@ -45,10 +51,10 @@ class JudgeEngine:
def test(self):
while not self.quit_event.isSet():
#pdb.set_trace()
# pdb.set_trace()
try:
submit = self.test_queue.get(True, self.config.fetch_interval)
except Queue.Empty:
except queue.Empty:
continue
tester = self.config.get_tester(submit.language)
if tester:
@@ -64,6 +70,8 @@ class JudgeEngine:
self.quit_event.set()
return
class JudgeError(Exception): pass
class JudgeError(Exception):
pass
# vim: set expandtab tabstop=4 shiftwidth=4: