title: UWSGI not running flask app when debugging due to postfork
body: <p>I have setup a basic Flask app that is using <code>pydevd</code> to remote debug our python app. We are also using the uwsgidecorators's <code>postfork()</code> method. The code looks something like this</p>
  
  <pre><code>from flask import Flask
  
  import sys
  sys.path.append('pycharm-debug.egg')  # replace by pycharm-debug.egg for Python 2.7
  import pydevd
  # the following line can be copied from "Run/Debug Configurations" dialog
  pydevd.settrace('localhost', port=4444, stdoutToServer=True, stderrToServer=True)
  
  
  print __name__
  
  application = Flask(__name__)
  
  
  @application.route('/')
  def hello_world():
      return 'Hello World!'
  
  
  def initialize():
      print "This is called"
  
  
  try:
      from uwsgidecorators import postfork
      postfork(initialize)
  except ImportError:
      pass
  
  
  if __name__ == '__main__':
      application.run(host='0.0.0.0', port=8055)
  </code></pre>
  
  <p>The uWSGI.ini file looks like this </p>
  
  <pre><code>[uwsgi]
  module = app
  socket = 0.0.0.0:8000
  master = true
  </code></pre>
  
  <p>Now when I try to run the <code>uwsgi ./uwsgi.ini</code> the debugger does break on the first line i.e. on <code>print __name__</code> but the application doesn't start up. One thing to note is that postfork() doesn't call the <code>intialize</code> method. After some trial and error I was able to run the application if I removed the <code>pydev.settrace</code> I need to be able to debug the application. Does anyone know what is going on here?</p>