title: How to exit with error from script to Airflow?
body: <p>Say I'm running:</p>
  
  <pre><code>t = BashOperator(
      task_id='import',
      bash_command="""python3 script.py '{{ next_execution_date }}' """,
      dag=dag)
  </code></pre>
  
  <p>And for some reason I want the script to exit with error and indicate airflow that he should retry this task.</p>
  
  <p>I tried to use <code>os._exit(1)</code> but Airflow mark the task as success.
  I know there is:</p>
  
  <pre><code>from airflow.exceptions import AirflowException
  raise AirflowException("error msg")
  </code></pre>
  
  <p>But this is more for functions written in a DAG. My script is independent and sometimes we run it alone regardless of airflow.</p>
  
  <p>Also the script is <code>Python3</code> while Airflow is running under Python 2.7
  It's seems excessive to install Airflow on <code>Python3</code> just for error handling.</p>
  
  <p>Is that any other solution?</p>