我正在使用烧瓶来处理包含指向文档的 URL 的请求。当请求到达时,URL 指向的文档被保存到一个文件中。文件被打开、处理并根据文档中的数据生成一个 json 字符串。json 字符串在响应中发送。
我的问题是关于它们之间的时间很短的请求。当 User1 在他的请求中发送 url_1 时,会保存 url_1 处的文档。User2 在打开来自 User1 的文档之前使用 url_2 发送请求。发送给 User1 的生成的 json 字符串是否基于 url_2 处的文档?这很有可能发生吗?
下图说明了该场景:
这是烧瓶应用程序的外观:
app = Flask(__name__)
@app.route("/process_document", methods=['GET'])
def process_document():
download_location = "document.txt"
urllib.request.urlretrieve(request.args.get('document_location'),download_location)
json = some_module.construct_json(download_location)
return json