You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ashb (via GitHub)" <gi...@apache.org> on 2026/10/09 10:18:01 UTC

Re: [PR] Fix misleading timetable Variable example in best practices [airflow]

ashb commented on code in PR #73945:
URL: https://github.com/apache/airflow/pull/73945#discussion_r4229051549


##########
airflow-core/docs/best-practices.rst:
##########
@@ -463,9 +463,15 @@ for any variable that contains sensitive data.
 
 Timetables
 ----------
-Avoid using Airflow Variables/Connections or accessing Airflow database at the top level of your timetable code.
-Database access should be delayed until the execution time of the Dag. This means that you should not have variables/connections retrieval
-as argument to your timetable class initialization or have Variable/connection at the top level of your custom timetable module.
+Avoid using Airflow Variables/Connections or accessing Airflow database anywhere in your timetable code: at the
+top level of the module, in ``__init__``, and in scheduling methods such as ``next_dagrun_info``. The scheduler
+rebuilds your timetable from the serialized Dag by calling ``deserialize``, which calls ``__init__`` again, so
+this code runs in the scheduler, outside of any task. Retrieving a Variable or Connection there fails and can
+crash the Dag processor or the scheduler.

Review Comment:
   We should probably fix that -- it shouldn't crash the whole process ideally. Fancy another PR?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org