Beispiel #1
0
def execute_command(command_to_exec: CommandType) -> None:
    """Executes command."""
    BaseExecutor.validate_command(command_to_exec)
    log.info("Executing command in Celery: %s", command_to_exec)

    if settings.EXECUTE_TASKS_NEW_PYTHON_INTERPRETER:
        _execute_in_subprocees(command_to_exec)
    else:
        _execute_in_fork(command_to_exec)
Beispiel #2
0
def execute_command(command_to_exec: CommandType) -> None:
    """Executes command."""
    BaseExecutor.validate_command(command_to_exec)
    log.info("Executing command in Celery: %s", command_to_exec)
    celery_task_id = app.current_task.request.id
    log.info(f"Celery task ID: {celery_task_id}")

    if settings.EXECUTE_TASKS_NEW_PYTHON_INTERPRETER:
        _execute_in_subprocess(command_to_exec, celery_task_id)
    else:
        _execute_in_fork(command_to_exec, celery_task_id)
Beispiel #3
0
def execute_command(command_to_exec: CommandType) -> None:
    """Executes command."""
    BaseExecutor.validate_command(command_to_exec)
    celery_task_id = app.current_task.request.id
    log.info("[%s] Executing command in Celery: %s", celery_task_id, command_to_exec)

    try:
        if settings.EXECUTE_TASKS_NEW_PYTHON_INTERPRETER:
            _execute_in_subprocess(command_to_exec, celery_task_id)
        else:
            _execute_in_fork(command_to_exec, celery_task_id)
    except Exception:
        Stats.incr("celery.execute_command.failure")
        raise
Beispiel #4
0
def execute_command(command_to_exec: CommandType) -> None:
    """Executes command."""
    BaseExecutor.validate_command(command_to_exec)
    log.info("Executing command in Celery: %s", command_to_exec)
    env = os.environ.copy()
    try:
        # pylint: disable=unexpected-keyword-arg
        subprocess.check_output(command_to_exec, stderr=subprocess.STDOUT,
                                close_fds=True, env=env)
        # pylint: disable=unexpected-keyword-arg
    except subprocess.CalledProcessError as e:
        log.exception('execute_command encountered a CalledProcessError')
        log.error(e.output)
        msg = 'Celery command failed on host: ' + get_hostname()
        raise AirflowException(msg)