You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "karunpoudel (via GitHub)" <gi...@apache.org> on 2023/06/07 00:22:24 UTC

[GitHub] [airflow] karunpoudel commented on a diff in pull request #31747: PythonVirtualenvOperator: termination error message in alert

karunpoudel commented on code in PR #31747:
URL: https://github.com/apache/airflow/pull/31747#discussion_r1220588789


##########
airflow/operators/python.py:
##########
@@ -423,11 +424,17 @@ def _execute_python_callable_in_subprocess(self, python_path: Path, tmp_dir: Pat
                     os.fspath(input_path),
                     os.fspath(output_path),
                     os.fspath(string_args_path),
+                    os.fspath(termination_log_path),
                 ]
             )
         except subprocess.CalledProcessError as e:
             if e.returncode in self.skip_on_exit_code:
                 raise AirflowSkipException(f"Process exited with code {e.returncode}. Skipping.")
+            elif termination_log_path.exists() and termination_log_path.stat().st_size > 0:
+                error_msg = f"Process returned non-zero exit status {e.returncode}.\n"
+                with open(termination_log_path) as file:
+                    error_msg += file.read()
+                raise AirflowException(error_msg) from None

Review Comment:
   Is there better exception than `AirflowException` that we can raise here?



-- 
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