Lee-W commented on code in PR #50371: URL: https://github.com/apache/airflow/pull/50371#discussion_r2084836196
########## airflow-core/src/airflow/dag_processing/processor.py: ########## @@ -94,6 +96,21 @@ def _parse_file_entrypoint(): def _parse_file(msg: DagFileParseRequest, log: FilteringBoundLogger) -> DagFileParsingResult | None: # TODO: Set known_pool names on DagBag! + + # Pre-import modules + # Read the file to pre-import airflow modules used. + # This prevents them from being re-imported from zero in each "processing" process + # and saves CPU time and memory. + + if conf.getboolean("scheduler", "parsing_pre_import_modules", fallback=True): + for module in iter_airflow_imports(msg.file): + try: + importlib.import_module(module) + except Exception as e: Review Comment: ```suggestion except Exception as e: ``` We probably should use concrete exception here instead -- 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-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org