0

My setup is simple. I load my server like this python gevent_wsgi_server.py.

When I execute the /block endpoint multiple times, request is rendered sequentially in my browser. 5 seconds each.

I am doing the monkey patch in the server before anything. I think it has to do something with the time module which I imported inside my app.py. But then again, wondering why patching didn't work.

This is my Application

# app.py
from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello, World! I am a flask app'

@app.route('/block')
def blocking_view():
    import time; time.sleep(5)
    return 'BLOCKING !'

This is the gevent WSGI server

# gevent_wsgi_server.py
from gevent import monkey; monkey.patch_all()
from gevent.pywsgi import WSGIServer
from app import app

if __name__ == "__main__":
    wsgi_server = WSGIServer(("0.0.0.0", 8000), app)
    wsgi_server.serve_forever()
bad programmer
  • 818
  • 7
  • 12

0 Answers0