mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
mq 增加日志设置
This commit is contained in:
parent
e1c2084e77
commit
f86ebd8ba3
@ -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()
|
||||
|
||||
@ -148,7 +148,7 @@ LOGGING = {
|
||||
}
|
||||
},
|
||||
'loggers': {
|
||||
'app_info_logger': {
|
||||
'app_info': {
|
||||
'handlers': ['app_info', "console"],
|
||||
'level': 'DEBUG',
|
||||
'propagate': True
|
||||
|
||||
Loading…
Reference in New Issue
Block a user