Exemplo n.º 1
0
def wrap_task(wrapped, instance, args, kwargs):
    task, *_ = args
    task_name = callable_name(task)
    app = application()

    with BackgroundTask(app, task_name):
        return wrapped(*args, **kwargs)
Exemplo n.º 2
0
    def perform(self):
        # This is the jobs own method to execute the task. Time
        # this as a background task where name is the name of
        # the queued task. This should also capture any record
        # any unhandled exceptions that occurred when running
        # the task.
 
        with BackgroundTask(application(), self.func_name):
            return _perform(self)
Exemplo n.º 3
0
def wrapper_GearmanWorker_on_job_execute(wrapped, instance, args, kwargs):
    def _bind_params(current_job, *args, **kwargs):
        return current_job

    # The background task is always created against the default
    # application specified by the agent configuration. The background
    # task is named after the name the task function was registered as,
    # and prefixed by the special 'Gearman' group.

    application = default_application()
    current_job = _bind_params(*args, **kwargs)

    with BackgroundTask(application, current_job.task, 'Gearman'):
        return wrapped(*args, **kwargs)
Exemplo n.º 4
0
def _nr_wrapper_BaseCommand_run_from_argv_(wrapped, instance, args, kwargs):
    def _args(argv, *args, **kwargs):
        return argv

    _argv = _args(*args, **kwargs)

    subcommand = _argv[1]

    commands = django_settings.instrumentation.scripts.django_admin
    startup_timeout = \
            django_settings.instrumentation.background_task.startup_timeout

    if subcommand not in commands:
        return wrapped(*args, **kwargs)

    application = register_application(timeout=startup_timeout)

    with BackgroundTask(application, subcommand, 'Django'):
        return wrapped(*args, **kwargs)