Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update python.rst with multi-Scheduler LocalExecutor info #32310

Merged
merged 15 commits into from
Jul 5, 2023
10 changes: 10 additions & 0 deletions docs/apache-airflow/howto/operator/python.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ Use the ``@task`` decorator to execute Python callables.
The ``@task`` decorator is recommended over the classic :class:`~airflow.operators.python.PythonOperator`
to execute Python callables.

.. note::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why here? It is importand and valid potint to mention but it works the same way for every other operator, so I guess it should be explained in https://airflow.apache.org/docs/apache-airflow/stable/core-concepts/executor/local.html#local-executor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@potiuk I missed that. I have made the changes in local.rst now. Let me know if that looks good

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@potiuk Updated now


When using the ``@task`` decorator with multiple Schedulers configured with ``executor = LocalExecutor`` in the [core] section of airflow.cfg, each scheduler will run a LocalExecutor. This means tasks would be processed in a distributed fashion across the machines running the Schedulers.

Some considerations should be taken into account:

- Restarting a Scheduler: If a scheduler is restarted, it may take some time for other schedulers to recognize the orphaned tasks and restart or fail them.

- Sharing of instances: While a single LocalExecutor allows tasks to share the same Python process and exchange information via variables, this is not possible when using multiple Schedulers, as each Scheduler will run in its own separate Python process.

.. exampleinclude:: /../../airflow/example_dags/example_python_operator.py
:language: python
:dedent: 4
Expand Down