nuclearpinguin commented on a change in pull request #6905: [AIRFLOW-6361] Run 
LocalTaskJob directly in Celery task
URL: https://github.com/apache/airflow/pull/6905#discussion_r361696059
 
 

 ##########
 File path: airflow/executors/celery_executor.py
 ##########
 @@ -59,17 +58,17 @@
 
 
 @app.task
-def execute_command(command_to_exec: str) -> None:
+def execute_command(command_to_exec: List[str]) -> None:
     """Executes command."""
     log = LoggingMixin().log
     log.info("Executing command in Celery: %s", command_to_exec)
-    env = os.environ.copy()
     try:
-        subprocess.check_call(command_to_exec, stderr=subprocess.STDOUT,
-                              close_fds=True, env=env)
-    except subprocess.CalledProcessError as e:
-        log.exception('execute_command encountered a CalledProcessError')
-        log.error(e.output)
+        parser = CLIFactory.get_parser()
+        # drop "airflow"
+        command_to_exec = command_to_exec[1:]
+        args = parser.parse_args(command_to_exec)
+        args.func(args)
 
 Review comment:
   Having a function will make it easier imho ✅

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to