title: Non-blocking concurrent wsgi server
body: <p>I am trying to be able to respond incoming web requests simultaneously, while processing of a request includes quite long IO call. I'm going to use gevent, as it's supposed to be "non-blocking"</p>
  
  <p>The problem I found is that requests are processed sequentially even though I have a lot of gevent threads. For some reason requests get served by single green thread.</p>
  
  <p>I have nginx (with default config which isn't relevant here I think), also I have uwsgi and simple wsgi app that emulates IO-blocking call as gevent.sleep(). Here they are:</p>
  
  <p><strong>uwsgi.ini</strong></p>
  
  <pre><code>[uwsgi]
  chdir = /srv/website
  home = /srv/website/env
  module = wsgi:app
  socket = /tmp/uwsgi_mead.sock
  #daemonize = /data/work/zx900/mob-effect.mead/logs/uwsgi.log
  processes = 1
  gevent = 100
  gevent-monkey-patch
  </code></pre>
  
  <p><strong>wsgi.py</strong></p>
  
  <pre><code>import gevent
  import time
  from flask import Flask
  
  app = Flask(__name__)
  
  @app.route("/")
  def hello():
      t0 = time.time()
      gevent.sleep(10.0)
      t1 = time.time()
      return "{1} - {0} = {2}".format(t0, t1, t1 - t0)
  </code></pre>
  
  <p>then I simultaneously (almost) open two tabs in my browser, and here is what I get as result:</p>
  
  <pre><code>1392297388.98 - 1392297378.98 = 10.0021491051 
  # first tab, processing finished at 1392297378.98
  
  1392297398.99 - 1392297388.99 = 10.0081849098 
  # second tab, processing started at 1392297398.99
  </code></pre>
  
  <p>As you can see, first call blocked execution of the view. What did I wrong? </p>