title: uWSGI, Flask and Parallel execution blocks
body: <p>I have a small API written in Python with Flask. It is a wrapper API around another API (which I don't control). I need to make several requests and I want to make them parallel. The first alternative was to use <code>grequests</code> but inexplicably the <code>uwsgi</code> server hanged and didn't respond. It took a while for it to reload workers after sending <code>HUP</code> signal to the master process. The code I was using is something like:</p>
  
  <pre><code>urls = [
      'http://www.example.com', 
      'http://www.example.net',
  ]
  urls = [grequests.get(x, hooks=dict(response=function_to_do_some_work))
          for url in urls]
  grequests.map(urls) # &lt;- here it hangs
  </code></pre>
  
  <p>I thought it was some problem with <code>gevent</code>/<code>grequests</code> so I reimplemented the solution using <code>multiprocessing.Pool</code>, like this:</p>
  
  <pre><code>urls = [
      'http://www.example.com', 
      'http://www.example.net',
  ]
  pool = multiprocessing.Pool(10)
  pool.map(function_to_do_some_work, urls) # &lt;- here it hangs
  </code></pre>
  
  <p>The problem here is not the code, that runs perfectly in the development environment. The problem is with the <code>uwsgi</code> and Python execution model, or something between those lines. I don't know where to start looking for answers here. The versions of the modules I'm using are:</p>
  
  <pre><code>Python 2.7.5
  grequests 0.2.0
  Flask 0.10.1
  uwsgi 2.0.9
  </code></pre>
  
  <p>What alternative of parallel execution should I use to perform several tasks at the same time, under this execution environment?</p>