title: mod_wsgi keeps restarting flask app
body: <p>From Flask's documentation, I have the following in my config:</p>
  
  <pre><code>&lt;VirtualHost *&gt;
      ServerName example.com
  
      WSGIDaemonProcess yourapplication user=user1 group=group1 threads=5
      WSGIScriptAlias / /var/www/yourapplication/yourapplication.wsgi
  
      &lt;Directory /var/www/yourapplication&gt;
          WSGIProcessGroup yourapplication
          WSGIApplicationGroup %{GLOBAL}
          Order deny,allow
          Allow from all
      &lt;/Directory&gt;
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>In my .wsgi file, I import the proper python file and import the flask app as application.  Everything works fine, but I added logging to that file because I suspected something was wrong.  Apparently, that wsgi file gets called every so often whenever a browser makes connection.  It restarts the app (or at least a new process).  I never noticed this, nor did I see it as a problem until I imported flask-login to manage authenticated sessions.  Now whenever I login, after some short time, the wsgi app is reloaded and the session history no longer exists.  In effect, I have to login every few seconds.  Is this the intended way mod_wsgi works?  I've tested my flask app running in standalone mode (flask's own devel server) and it works flawlessly.</p>
  
  <p>In a way it's a duplicate, but it's also not.  The server code isn't buggy. It's just mod_wsgi restarts the application over and over. Thanks for linking to the other post, though!</p>