Improve upload_file by properly supporting streaming files

This commit is contained in:
Lonami Exo
2020-07-15 14:35:42 +02:00
parent bfb8de2736
commit de17a19168
2 changed files with 87 additions and 42 deletions

View File

@@ -3,6 +3,7 @@ import asyncio
import enum
import os
import struct
import inspect
from hashlib import sha1
@@ -107,6 +108,13 @@ def retry_range(retries):
yield 1 + attempt
async def _maybe_await(value):
if inspect.isawaitable(value):
return await value
else:
return value
async def _cancel(log, **tasks):
"""
Helper to cancel one or more tasks gracefully, logging exceptions.