上下文
/articles?channel_id=123-> thread A ->123
/articles?channel_id=124 -> thread B ->124
请求上下文和应用上下文。
应用上下文
from flask import current_app app = Flask(__name__) curren.app.config.get("test") with app.app_context(): #出现working outside of appliction context print(current_app.redis_cli) #with这里是绑定应用
#请求上下文
with app.request_context(envirion): pritn(request.path) #environ是wsgi对应的一些字典信息。
原理
threadlocal线程局部变量