【发布时间】:2021-12-24 21:20:22
【问题描述】:
@app.route("/test")
def test_func():
@after_this_request
def delete_file(response):
os.remove('test.txt')
return response
return send_file('test.txt')
我的 test.txt 与我的代码位于同一目录中。我想做的就是删除我发送的文件,但是当我访问这个 GET 方法时,我遇到了以下错误:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'test.txt' 127.0.0.1 - - [12/Nov/2021 19:47:53] "GET /test HTTP/1.1" 500 -
提前谢谢你
【问题讨论】:
-
您可以考虑使用celery。