Esempio n. 1
0
    def decorator(*args, **kwargs):

        from pymacaron.log import pymlogger

        pymlog = pymlogger(__name__)
        pymlog.info(" ")
        pymlog.info(" ")
        pymlog.info("=> INCOMING REQUEST %s %s -> %s" % (endpoint.method, endpoint.path, f.__name__))
        pymlog.info(" ")
        pymlog.info(" ")

        res = f(*args, **kwargs)

        pymlog.info("<= DONE %s %s -> %s" % (endpoint.method, endpoint.path, f.__name__))
        pymlog.info(" ")
        pymlog.info(" ")

        return res
Esempio n. 2
0
import inspect
from flask import Flask, request, has_request_context
from functools import wraps, update_wrapper
import types
from subprocess import Popen
from pymacaron.log import pymlogger
from pymacaron.auth import get_user_token
from pymacaron.auth import load_auth_token
from pymacaron.utils import timenow
from pymacaron.crash import postmortem
from pymacaron_async.serialization import model_to_task_arg
from pymacaron_async.serialization import task_arg_to_model
from pymacaron_async.app import app
from pymacaron_async.cmd import get_celery_cmd

log = pymlogger(__name__)

flaskapp = Flask('pym-async')


def is_celery_task():
    """Return true if the code is being executed inside a Celery task, False otherwise"""
    return True if 'celery worker' in ' '.join(sys.argv).lower() else False


def kill_celery():
    """Kill celery workers"""
    for line in os.popen(
            "ps ax | grep 'celery worker -E -A pymacaron_async' | grep -v grep"
    ):
        fields = line.split()