<commit_before># coding=utf-8
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, redis_config


@app.task
def judge(submission_id, time_limit, memory_limit, test_case_id):
    try:
        command = "%s run -t -i --privileged --rm=true " \
                  "-v %s:/var/judger/test_case/ " \
                  "-v %s:/var/judger/code/ " \
                  "%s " \
                  "python judge/judger/run.py " \
                  "--solution_id %s --time_limit %s --memory_limit %s --test_case_id %s" % \
                  (docker_config["docker_path"],
                   test_case_dir,
                   source_code_dir,
                   docker_config["image_name"],
                   submission_id, str(time_limit), str(memory_limit), test_case_id)
        subprocess.call(command, shell=docker_config["shell"])
    except Exception as e:
        print e
        conn = MySQLdb.connect(db=submission_db["db"],
                               user=submission_db["user"],
                               passwd=submission_db["password"],
                               host=submission_db["host"],
                               port=submission_db["port"],
                               character="utf8")

        cur = conn.cursor()
        cur.execute("update submission set result=%s, info=%s where id=%s",
                    (result["system_error"], str(e), submission_id))
        conn.commit()
        conn.close()
    r = redis.Redis(host=redis_config["host"], port=redis_config["port"], db=redis_config["db"])
    r.decr("judge_queue_length")<commit_msg>add message to mq<commit_after># coding=utf-8
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, redis_config


@app.task
def judge(submission_id, time_limit, memory_limit, test_case_id):
    try:
        command = "%s run -t -i --privileged --rm=true " \
                  "-v %s:/var/judger/test_case/ " \
                  "-v %s:/var/judger/code/ " \
                  "%s " \
                  "python judge/judger/run.py " \
                  "--solution_id %s --time_limit %s --memory_limit %s --test_case_id %s" % \
                  (docker_config["docker_path"],
                   test_case_dir,
                   source_code_dir,
                   docker_config["image_name"],
                   submission_id, str(time_limit), str(memory_limit), test_case_id)
        subprocess.call(command, shell=docker_config["shell"])
    except Exception as e:
        print e
        conn = MySQLdb.connect(db=submission_db["db"],
                               user=submission_db["user"],
                               passwd=submission_db["password"],
                               host=submission_db["host"],
                               port=submission_db["port"],
                               character="utf8")

        cur = conn.cursor()
        cur.execute("update submission set result=%s, info=%s where id=%s",
                    (result["system_error"], str(e), submission_id))
        conn.commit()
        conn.close()
    r = redis.Redis(host=redis_config["host"], port=redis_config["port"], db=redis_config["db"])
    r.decr("judge_queue_length")
    r.lpush("queue", submission_id)

{'fraction_non_alphanumeric': 0.12091967073516889, 'fraction_numerical': 0.0011353959693443088, 'mean_word_length': 1.8932676518883416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6937792', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1000, 'n_words': 198}