判题暂时可以跑起来了,真要被自己蠢哭了

This commit is contained in:
virusdefender
2015-08-12 19:55:41 +08:00
parent 92ab7e5fb2
commit 66d3cd3bfe
13 changed files with 43 additions and 31 deletions

View File

@@ -1,5 +1,10 @@
# coding=utf-8
from __future__ import absolute_import
from celery import Celery
from .settings import redis_config
app = Celery("judge", broker="redis://localhost:6379/0", include=["judger_controller.tasks"])
app = Celery("judge", broker="redis://" +
redis_config["host"] + ":" +
str(redis_config["port"]) +
"/" + str(redis_config["db"]),
include=["judger_controller.tasks"])

View File

@@ -0,0 +1,6 @@
# coding=utf-8
redis_config = {
"host": "127.0.0.1",
"port": 6379,
"db": 0
}

View File

@@ -8,13 +8,13 @@ import subprocess32 as subprocess
def judge(solution_id, time_limit, memory_limit, test_case_id):
try:
subprocess.call("docker run -t -i --privileged --rm=true "
"-v /var/test_case/:/var/judger/test_case/ "
"-v /Users/virusdefender/Desktop/test_case/:/var/judger/test_case/ "
"-v /Users/virusdefender/Desktop/:/var/judger/code/ "
"-p 27017:27017 "
"judger "
"python judger/run.py "
"--solution_id %s --time_limit %s --memory_limit %s --test_case_id %s" %
(solution_id, str(time_limit), str(memory_limit), test_case_id),
timeout=(time_limit / 100) * 20, shell=True)
# 如果设置的最长运行时间小于1000毫秒那么/1000就是0处理一下这个情况设置为两秒
timeout=(time_limit / 1000 * 3) or 2, shell=True)
except subprocess.TimeoutExpired:
print "docker timeout"