mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-09-21 08:23:20 +00:00
修改计数方式
This commit is contained in:
parent
e4ff9e642a
commit
4b49fa5050
@ -10,8 +10,6 @@ from settings import docker_config, source_code_dir, test_case_dir, submission_d
|
|||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
def judge(submission_id, time_limit, memory_limit, test_case_id):
|
def judge(submission_id, time_limit, memory_limit, test_case_id):
|
||||||
r = redis.Redis(host=redis_config["host"], port=redis_config["port"], db=redis_config["db"])
|
|
||||||
r.incr("judge_queue_length")
|
|
||||||
try:
|
try:
|
||||||
command = "%s run -t -i --privileged --rm=true " \
|
command = "%s run -t -i --privileged --rm=true " \
|
||||||
"-v %s:/var/judger/test_case/ " \
|
"-v %s:/var/judger/test_case/ " \
|
||||||
@ -39,4 +37,5 @@ def judge(submission_id, time_limit, memory_limit, test_case_id):
|
|||||||
(result["system_error"], str(e), submission_id))
|
(result["system_error"], str(e), submission_id))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
|
r = redis.Redis(host=redis_config["host"], port=redis_config["port"], db=redis_config["db"])
|
||||||
r.decr("judge_queue_length")
|
r.decr("judge_queue_length")
|
@ -1,5 +1,6 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
import json
|
import json
|
||||||
|
import redis
|
||||||
|
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
|
||||||
@ -7,6 +8,7 @@ from rest_framework.views import APIView
|
|||||||
|
|
||||||
from judge.judger.result import result
|
from judge.judger.result import result
|
||||||
from judge.judger_controller.tasks import judge
|
from judge.judger_controller.tasks import judge
|
||||||
|
from judge.judger_controller.settings import redis_config
|
||||||
from account.decorators import login_required
|
from account.decorators import login_required
|
||||||
from account.models import SUPER_ADMIN
|
from account.models import SUPER_ADMIN
|
||||||
from problem.models import Problem
|
from problem.models import Problem
|
||||||
@ -41,6 +43,10 @@ class SubmissionAPIView(APIView):
|
|||||||
except Exception:
|
except Exception:
|
||||||
return error_response(u"提交判题任务失败")
|
return error_response(u"提交判题任务失败")
|
||||||
|
|
||||||
|
# 增加redis 中判题队列长度的计数器
|
||||||
|
r = redis.Redis(host=redis_config["host"], port=redis_config["port"], db=redis_config["db"])
|
||||||
|
r.incr("judge_queue_length")
|
||||||
|
|
||||||
return success_response({"submission_id": submission.id})
|
return success_response({"submission_id": submission.id})
|
||||||
else:
|
else:
|
||||||
return serializer_invalid_response(serializer)
|
return serializer_invalid_response(serializer)
|
||||||
|
Loading…
Reference in New Issue
Block a user