title: Airflow - local variable 'filename' referenced before assignment
body: <p>I'm having an annoying issue in airflow that keeps queuing a lot of tasks in the UI and in order to keep them running I have to restart the scheduler and the workers. My Airflow configuration is using CeleryExecutor, running in 2 workers with the help of Reddis. </p>
  
  <p>I had a look to the logs in the workers and it's showing me this:</p>
  
  <pre><code>Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]: airflow.exceptions.AirflowException: dag_id could not be found: dc2_phd_nw_5225_processing. Either the dag did not exist or it failed to parse.
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]: [2018-02-05 06:53:37,385: ERROR/ForkPoolWorker-17] Command 'airflow run dc2_phd_nw_5225_processing phd_5225_stage_4_add_new_gcs_segments_to_etl_unload_C 2018-02-04T02:00:00 --local --pool dc2 -sd /home/airflow/airflow/dags/doubleclick/dc2_processing.py' returned non-zero exit status 1
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]: [2018-02-05 06:53:37,388: ERROR/ForkPoolWorker-17] Task airflow.executors.celery_executor.execute_command[a1821a3b-5ca5-430f-84ce-eb0625a7bbca] raised unexpected: AirflowException('Celery command failed',)
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]: Traceback (most recent call last):
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]:   File "/usr/local/lib/python3.5/dist-packages/airflow/executors/celery_executor.py", line 56, in execute_command
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]:     subprocess.check_call(command, shell=True)
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]:   File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]:     raise CalledProcessError(retcode, cmd)
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]: subprocess.CalledProcessError: Command 'airflow run dc2_phd_nw_5225_processing phd_5225_stage_4_add_new_gcs_segments_to_etl_unload_C 2018-02-04T02:00:00 --local --pool dc2 -sd /home/airflow/airflow/dags/doubleclick/dc2_processing.py' returned non-zero exit status 1
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]: During handling of the above exception, another exception occurred:
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]: Traceback (most recent call last):
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]:   File "/usr/local/lib/python3.5/dist-packages/celery/app/trace.py", line 367, in trace_task
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]:     R = retval = fun(*args, **kwargs)
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]:   File "/usr/local/lib/python3.5/dist-packages/celery/app/trace.py", line 622, in __protected_call__
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]:     return self.run(*args, **kwargs)
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]:   File "/usr/local/lib/python3.5/dist-packages/airflow/executors/celery_executor.py", line 59, in execute_command
  Feb 05 06:53:37 ip-172-31-46-75 airflow[3656]:     raise AirflowException('Celery command failed')
  </code></pre>
  
  <p>I followed this <a href="https://stackoverflow.com/a/44540151/2198720">solution</a> that indicates to use <strong>--raw</strong> after airflow run command to see the real exception and it says the following:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/usr/local/bin/airflow", line 28, in &lt;module&gt;
      args.func(args)
    File "/usr/local/lib/python3.5/dist-packages/airflow/bin/cli.py", line 403, in run
      print("Logging into: " + filename)
  UnboundLocalError: local variable 'filename' referenced before assignment
  </code></pre>
  
  <p>Has anyone has the same issue or any idea how to solve it?</p>