简体   繁体   English

在 Sanic 框架上上传时如何增加超时时间?

[英]How to increase timeout while uploading on the Sanic framework?

I have a method in Sanic for uploading files.我在 Sanic 中有一种上传文件的方法。 Sometimes my file size is large or the connection between server and clients is poor So, in this situation I lose my request because the clients occur with a timeout exception.有时我的文件很大或者服务器和客户端之间的连接很差所以,在这种情况下,我会丢失我的请求,因为客户端发生超时异常。 I want to increase timeout on top of a specific method.我想在特定方法之上增加超时。

# 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

As of Sanic 20.3 this is not possible but such functionality is planned in a future release.从 Sanic 20.3 开始,这是不可能的,但计划在未来版本中使用此类功能。

https://github.com/huge-success/sanic/pull/1791 allows adjusting request maximum size in streaming handlers, and also resets the request timeout whenever there is I/O, so that lengthy uploads should not timeout. https://github.com/huge-success/sanic/pull/1791允许在流处理程序中调整请求最大大小,并在有 I/O 时重置请求超时,以便长时间上传不会超时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM