How does Flask keep the request global threadsafe

旧街凉风 提交于 2019-12-12 10:35:23

问题


In flask every function has access to a request global. How do the designers of flask stop that global from being overwritten in the middle of one request when another one starts?


回答1:


It's a threadlocal, not a true global. Since each thread can only be dealing with one request at a time, there's no danger of interference.

In fact there's a full description of exactly this in the Flask docs here.

(Still doesn't necessarily make it a good design, of course.)



来源:https://stackoverflow.com/questions/23726788/how-does-flask-keep-the-request-global-threadsafe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!