mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-08 04:52:30 +00:00
Improve upload_file by properly supporting streaming files
This commit is contained in:
@@ -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.
|
||||
|
Reference in New Issue
Block a user