How to dispatch requests for one URL to multiple threads?
Question: This is a test application:

    
    
    #!/usr/bin/env python
    
    from flask import Flask
    from time import sleep
    
    application = Flask(__name__)
    application.debug = True
    
    @application.route('/a')
    @application.route('/b')
    @application.route('/c')
    def a():
        sleep(10)
        return 'Hello world.'
    
    if __name__ == '__main__':
        application.run()
    

This application is deployed on Apache:

    
    
    WSGIDaemonProcess Test processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup Test
    

if you

  * request /a at 00:00
  * request /b at 00:01
  * request /c at 00:02

, you will

  * receive response from /a at 00:10
  * receive response from /b at 00:11
  * receive response from /c at 00:12

But if you

  * request /a at 00:00
  * request /a at 00:01
  * request /a at 00:02

, you will

  * receive response from /a at 00:10
  * receive response from /a at 00:20
  * receive response from /a at 00:30

So I guess that every request for one URL is processed in one thread. Now I
intend to develop a long-pulling server, I think I need to dispatch every
request to a independent thread to avoid block subsequent requests. What
should I do?


Answer: This problem has been solved. My guess is incorrect, the truth is:  
In Chrome browser, if two requests composed of identical protocol, hostname,
port and path, the later request will not send until the prior request close.  
The blocked thing was not server but browser.

