title: gunicorn Connection in use for python flask
body: <p>I recently changed my Heroku Python Flask app from the '<em>small application</em>' format to the 'simple package' format based from <a href="http://flask.pocoo.org/docs/0.10/quickstart/" rel="nofollow">flask documentation</a> (De-coupling everything in <code>app.py</code> into separate subdirectories)</p>
  
  <p>The application runs correctly using</p>
  
  <pre><code>&gt; python runserver.py
  </code></pre>
  
  <p>However, executing</p>
  
  <pre><code>gunicorn runserver:app --log-file=- 
  </code></pre>
  
  <p>outputs:</p>
  
  <pre><code>"Starting gunicorn .... connection in use error" (loops forever)
  </code></pre>
  
  <p>My runserver.py configuration is:</p>
  
  <pre><code> from re3 import app
   app.run(debug=True)
  </code></pre>
  
  <p>__init__.py configuration:</p>
  
  <pre><code>import os
  from flask import Flask
  from flask import render_template
  app = Flask(__name__)
  import views
  </code></pre>
  
  <p>view.py configuration:</p>
  
  <pre><code>from re3 import app
  @app.route('/')
  def index():
      return 'Hello World!'
  </code></pre>
  
  <p>What is changing in the two executions?</p>