gpt4 book ai didi

flask - Gevent 和 flask - 线程本地

转载 作者:行者123 更新时间:2023-12-03 16:24:58 28 4
gpt4 key购买 nike

运行基于 Gevent 的服务器时,在 flask 中使用“g”的风险有哪些?

还是“无”意味着猴子修补使 flask 使用greenlet本地变量而不是线程本地变量?

最佳答案

Flask 根据其文档支持使用 greenlets:

Flask uses thread local objects (context local objects in fact, they support greenlet contexts as well) for request, session and an extra object you can put your own things on (g).



由于这种支持,使用 g 没有风险。使用 gevent 时。

阅读 http://flask.pocoo.org/docs/design/了解更多信息。

关于flask - Gevent 和 flask - 线程本地,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14551554/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com