mq 增加日志设置
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
# coding=utf-8
|
||||
import json
|
||||
import logging
|
||||
import redis
|
||||
from judge.judger_controller.settings import redis_config
|
||||
from judge.judger.result import result
|
||||
from submission.models import Submission
|
||||
from problem.models import Problem
|
||||
|
||||
logger = logging.getLogger("app_info")
|
||||
|
||||
|
||||
class MessageQueue(object):
|
||||
def __init__(self):
|
||||
@@ -15,11 +17,11 @@ class MessageQueue(object):
|
||||
def listen_task(self):
|
||||
while True:
|
||||
submission_id = self.conn.blpop(self.queue, 0)[1]
|
||||
print submission_id
|
||||
logger.debug("receive submission_id: " + submission_id)
|
||||
try:
|
||||
submission = Submission.objects.get(id=submission_id)
|
||||
except Submission.DoesNotExist:
|
||||
print "error 1"
|
||||
logger.warning("Submission does not exist, submission_id: " + submission_id)
|
||||
pass
|
||||
|
||||
if submission.result == result["accepted"]:
|
||||
@@ -29,9 +31,9 @@ class MessageQueue(object):
|
||||
problem.total_accepted_number += 1
|
||||
problem.save()
|
||||
except Problem.DoesNotExist:
|
||||
print "error 2"
|
||||
logger.warning("Submission problem does not exist, submission_id: " + submission_id)
|
||||
pass
|
||||
|
||||
|
||||
print "mq running"
|
||||
logger.debug("Start message queue")
|
||||
MessageQueue().listen_task()
|
||||
|
||||
Reference in New Issue
Block a user