开发者社区 问答 正文

Connexion Python框架设置多进程

我尝试配置Connexion以设置Flask框架中可能的进程或线程数。这在Flask中是可能的,但似乎Connexion没有将此配置发送到Flask。我阅读了Connexion文档,但未找到任何内容。这可能吗?

app = connexion.App(__name__, specification_dir='swagger/', debug=False, processes=4)
app.run(port=8080, server='gevent')

我尝试在connexion.App中设置参数,但是您无法设置此参数。

连接版本:

connexion==1.1.9

展开
收起
祖安文状元 2020-02-21 15:56:04 5793 分享 版权
1 条回答
写回答
取消 提交回答
  • 我找到了解决方法。使用uWSGI运行应用程序。您可以将Flask WSGI应用程序与任何WSGI容器一起使用。将Flask与uWSGI一起使用

    这是一个例子:

    $ sudo pip3 install uwsgi
    $ uwsgi --socket 0.0.0.0:8080 --protocol=http --callable app --file app.py --master -p 4  # use 4 worker processes
    
    2020-02-21 15:56:13
    赞同 47 展开评论