<commit_before>import json
from subprocess import Popen, PIPE, STDOUT

from celery.task import task
from django.conf import settings
import redisutils


def run(script):
    p = Popen(script, stdout=PIPE, stderr=STDOUT, shell=True)
    out, err = p.communicate()
    return p.returncode, out, err


@task(ignore_result=True)
def update_app(name, payload):
    redis = redisutils.connections['master']
    lock = redis.lock('updater.%s' % name, timeout=300)

    try:
        app_config = settings.APP_UPDATERS[name]
    except KeyError:
        return

    if 'ref' in app_config and payload['ref'] != app_config['ref']:
        return

    if not lock.acquire(False):
        update_app.retry()

    script = app_config['script']
    outfile = app_config.get('outfile')

    l = update_app.get_logger()
    l.info("Running: %s" % script)<commit_msg>publish to redis when an updater is locked<commit_after>import json
from subprocess import Popen, PIPE, STDOUT

from celery.task import task
from django.conf import settings
import redisutils


def run(script):
    p = Popen(script, stdout=PIPE, stderr=STDOUT, shell=True)
    out, err = p.communicate()
    return p.returncode, out, err


@task(ignore_result=True)
def update_app(name, payload):
    redis = redisutils.connections['master']
    lock = redis.lock('updater.%s' % name, timeout=300)

    try:
        app_config = settings.APP_UPDATERS[name]
    except KeyError:
        return

    if 'ref' in app_config and payload['ref'] != app_config['ref']:
        return

    if not lock.acquire(False):
        redis.publish('update.%s.locked' % name, json.dumps(payload))
        update_app.retry()

    script = app_config['script']
    outfile = app_config.get('outfile')

    l = update_app.get_logger()
    l.info("Running: %s" % script)
{'fraction_non_alphanumeric': 0.11951083935519734, 'fraction_numerical': 0.0033351862145636463, 'mean_word_length': 3.5454545454545454, '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': '313873', 'n_tokens_mistral': 614, 'n_tokens_neox': 591, 'n_words': 147}