如何在 Sanic 框架上上传时增加超时?
How to increase timeout while uploading on the Sanic framework?
我在Sanic中有上传文件的方法。有时我的文件很大或者服务器和客户端之间的连接很差所以,在这种情况下我失去了我的请求,因为客户端出现超时异常。我想在特定方法之上增加超时。
# I want to define set timeout period here
# @set_imeout(4 * 60)
@song.route('/upload', methods=["POST"])
@is_authenticated()
@required_roles(['cafe'])
@jsonify
async def process_upload(request):
# upload method
do something for upload
从 Sanic 20.3 开始,这是不可能的,但计划在未来的版本中提供此类功能。
https://github.com/huge-success/sanic/pull/1791 允许在流式处理程序中调整请求的最大大小,并在存在 I/O 时重置请求超时,这样冗长的上传就不会超时。
我在Sanic中有上传文件的方法。有时我的文件很大或者服务器和客户端之间的连接很差所以,在这种情况下我失去了我的请求,因为客户端出现超时异常。我想在特定方法之上增加超时。
# I want to define set timeout period here
# @set_imeout(4 * 60)
@song.route('/upload', methods=["POST"])
@is_authenticated()
@required_roles(['cafe'])
@jsonify
async def process_upload(request):
# upload method
do something for upload
从 Sanic 20.3 开始,这是不可能的,但计划在未来的版本中提供此类功能。
https://github.com/huge-success/sanic/pull/1791 允许在流式处理程序中调整请求的最大大小,并在存在 I/O 时重置请求超时,这样冗长的上传就不会超时。