yuqian90 commented on a change in pull request #6624: [AIRFLOW-6026] Use contextlib to redirect stderr and stdout URL: https://github.com/apache/airflow/pull/6624#discussion_r361074991
########## File path: airflow/jobs/scheduler_job.py ########## @@ -122,45 +123,40 @@ def _run_file_processor(result_channel, # This helper runs in the newly created process log = logging.getLogger("airflow.processor") - stdout = StreamLogWriter(log, logging.INFO) - stderr = StreamLogWriter(log, logging.WARN) - set_context(log, file_path) setproctitle("airflow scheduler - DagFileProcessor {}".format(file_path)) try: # redirect stdout/stderr to log - sys.stdout = stdout - sys.stderr = stderr - - # Re-configure the ORM engine as there are issues with multiple processes - settings.configure_orm() - - # Change the thread name to differentiate log lines. This is - # really a separate process, but changing the name of the - # process doesn't work, so changing the thread name instead. - threading.current_thread().name = thread_name - start_time = time.time() - - log.info("Started process (PID=%s) to work on %s", - os.getpid(), file_path) - scheduler_job = SchedulerJob(dag_ids=dag_id_white_list, log=log) - result = scheduler_job.process_file(file_path, - zombies, - pickle_dags) - result_channel.send(result) - end_time = time.time() - log.info( - "Processing %s took %.3f seconds", file_path, end_time - start_time - ) + with redirect_stdout(StreamLogWriter(log, logging.INFO)),\ Review comment: @mik-laj @ashb @kaxil where is this line supposed to redirect the DagFileProcessor logs/stdout/stderr to? In CI (using breeze), my observation is that for each DAG, it redirects to individual log files which are in this directory. Looks like it concatenated the absolute path to the dag definition file behind AIRFLOW_HOME. `/root/airflow/opt/airflow/airflow/example_dags/`. Is that expected? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services