➜ ~/projects siege -c 10-r 1 'http://127.0.0.1:5000/test' -v ** SIEGE 4.0.4 ** Preparing 10 concurrent users for battle. The server is now under siege... HTTP/1.120016.02secs:9 bytes ==> GET /test HTTP/1.120016.02secs:9 bytes ==> GET /test HTTP/1.120016.02secs:9 bytes ==> GET /test HTTP/1.120016.02secs:9 bytes ==> GET /test HTTP/1.120016.02secs:9 bytes ==> GET /test HTTP/1.120016.03secs:9 bytes ==> GET /test HTTP/1.120016.02secs:9 bytes ==> GET /test HTTP/1.120016.02secs:9 bytes ==> GET /test HTTP/1.120020.03secs:9 bytes ==> GET /test HTTP/1.120020.04secs:9 bytes ==> GET /test
尝试multiprocess
问题解决
1 2 3 4 5
@app.route('/test', methods=['GET', 'POST']) deftest(): p = multiprocessing.Process(target=socket_block, args=()) p.start() return'hello'
使用 siege 进行测试, 请求没有被阻塞
1 2 3 4 5 6 7 8 9
➜ ~/projects siege -c 5-r 1 'http://127.0.0.1:5000/test' -v ** SIEGE 4.0.4 ** Preparing 5 concurrent users for battle. The server is now under siege... HTTP/1.12000.01secs:5 bytes ==> GET /test HTTP/1.12000.02secs:5 bytes ==> GET /test HTTP/1.12000.03secs:5 bytes ==> GET /test HTTP/1.12000.03secs:5 bytes ==> GET /test HTTP/1.12000.04secs:5 bytes ==> GET /test