mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-04 03:22:06 +00:00
增加队列长度统计信息
This commit is contained in:
parent
f158d66c57
commit
096873c028
@ -1,14 +1,21 @@
|
||||
# coding=utf-8
|
||||
# from __future__ import absolute_import
|
||||
import datetime
|
||||
import redis
|
||||
import MySQLdb
|
||||
import subprocess
|
||||
from ..judger.result import result
|
||||
from ..judger_controller.celery import app
|
||||
from settings import docker_config, source_code_dir, test_case_dir, submission_db
|
||||
from settings import docker_config, source_code_dir, test_case_dir, submission_db, redis_config
|
||||
|
||||
|
||||
@app.task
|
||||
def judge(submission_id, time_limit, memory_limit, test_case_id):
|
||||
# 先更新判题队列长度
|
||||
r = redis.StrictRedis(host=redis_config["host"], port=redis_config["port"], db=redis_config["db"])
|
||||
length = r.incr("queue_length")
|
||||
now = datetime.datetime.now()
|
||||
# 使用hash key是今天的日期 value 的 key 是当前时分秒 12:02:03 value 是队列长度
|
||||
r.hset(str(datetime.date.today()), ":".join([str(now.hour), str(now.minute), str(now.second)]), length)
|
||||
try:
|
||||
command = "%s run -t -i --privileged --rm=true " \
|
||||
"-v %s:/var/judger/test_case/ " \
|
||||
@ -36,3 +43,7 @@ def judge(submission_id, time_limit, memory_limit, test_case_id):
|
||||
(result["system_error"], str(e), submission_id))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
r.decr("queue_length")
|
||||
now = datetime.datetime.now()
|
||||
# 使用hash key是今天的日期 value 的 key 是当前时分秒 12:02:03 value 是队列长度
|
||||
r.hset(str(datetime.date.today()), ":".join([str(now.hour), str(now.minute), str(now.second)]), length)
|
||||
|
Loading…
Reference in New Issue
Block a user