简体   繁体   中英

How to increase timeout while uploading on the Sanic framework?

I have a method in Sanic for uploading files. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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