gpt4 book ai didi

python - Flask框架中thread local是什么意思?

转载 作者:太空狗 更新时间:2023-10-29 20:28:39 25 4
gpt4 key购买 nike

<分区>

我正在评估 python 框架以构建 REST API。我研究过包括 Flask 在内的许多框架,发现 Flask 非常有趣且易于使用,具有构建 REST Web 服务所需的所有功能。

我没有得到的一件事是在 flask 文档中提到它使用“本地线程并且存在可伸缩性问题”。

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). Why is that and isn’t that a bad idea? Yes it is usually not such a bright idea to use thread locals. They cause troubles for servers that are not based on the concept of threads and make large applications harder to maintain. However Flask is just not designed for large applications or asynchronous servers. Flask wants to make it quick and easy to write a traditional web application.

谁能帮我理解这一点,提到了哪些可扩展性问题以及其他框架如何处理这个问题?

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