Using Gevent in flask: API is not asynchronous

后端 未结 3 2081
死守一世寂寞
死守一世寂寞 2021-01-15 23:16

Earlier I was using Waitress. Now I\'m using Gevent to run my Flask app that has only one API

from flask import Flask, request, jsonify
import documentUtil
fr         


        
3条回答
  •  温柔的废话
    2021-01-15 23:44

    We use Gunicorn to run Flask in multiple processes. You get more juice out of python that way + auto restarts and stuff. Sample config file:

    import multiprocessing
    
    bind = "0.0.0.0:80"
    workers = (multiprocessing.cpu_count() * 2) + 1
    # ... additional config
    

    Then run with something like

    gunicorn --config /path/to/file application.app
    

提交回复
热议问题