Skip to content

Python operators are printing more than one task log at a time #21982

@rustikk

Description

@rustikk

Apache Airflow version

main (development)

What happened

When using the python operator on scheduled runs the task logs are repeating multiple times. This issue doesn't occur when using the web UI to trigger the dags
Screen Shot 2022-03-03 at 4 24 09 PM

What you expected to happen

I expected the task details for each task to show only one print out of that tasks logs

How to reproduce

from airflow.models import DAG
from airflow.operators.python import PythonOperator

from datetime import datetime, timedelta

dag_name = "test_uri_generation"

def dummy_check4bugs():
    pass

with DAG(
    dag_id=dag_name,
    start_date=datetime(2021,1, 1),
    schedule_interval=timedelta(days=30, hours=12),
) as dag:

    t0 = PythonOperator(
        task_id="add_conn",
        #python_callable=add_conn,
        python_callable=dummy_check4bugs,
    )

    t1 = PythonOperator(
        task_id="check_uri_generation",
        #python_callable=check_uri_gen,
        python_callable=dummy_check4bugs,
    )
t0 >> t1

Operating System

Docker

Versions of Apache Airflow Providers

No response

Deployment

Docker-Compose

Deployment details

Airflow Breeze

Anything else

This bug occurs every time though only on scheduled runs and the first dag that runs typically repeats the logs the most.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions