Pebble32 commented on code in PR #73945: URL: https://github.com/apache/airflow/pull/73945#discussion_r4229093790
########## 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: Yeah absolutely! -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
