GitHub user bangbangDong created a discussion: SubprocessHook did not throw an
exception correctly
airflow version 2.10.4
If the test.py file does not exist, task.bash throws an exception correctly,
and subprocesshook is displayed as running properly.
```python
import sys
from datetime import datetime, timedelta
from airflow import DAG
from airflow.decorators import task
from airflow.utils.trigger_rule import TriggerRule
from airflow.hooks.subprocess import SubprocessHook
PYTHON_PATH = sys.base_prefix + "/bin/python"
sub_hook = SubprocessHook()
with DAG(
dag_id="test_base_env",
schedule=timedelta(seconds=5),
start_date=datetime(2024, 1, 1),
tags=["test"],
catchup=False,
dagrun_timeout=timedelta(seconds=300),
max_active_runs=1,
)as dag:
@task
def external():
sub_hook.run_command(["python", "test.py"])
return None
@task.bash
def test2():
return "python test.py"
external() >> test2()
```

GitHub link: https://github.com/apache/airflow/discussions/45450
----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]