mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-09 05:19:41 +00:00
Add experimental support for async sessions (#4667)
There no plans for this to ever be non-experimental in v1.
This commit is contained in:
@@ -14,6 +14,7 @@ import os
|
||||
import pathlib
|
||||
import re
|
||||
import struct
|
||||
import warnings
|
||||
from collections import namedtuple
|
||||
from mimetypes import guess_extension
|
||||
from types import GeneratorType
|
||||
@@ -1557,3 +1558,11 @@ def _photo_size_byte_count(size):
|
||||
return max(size.sizes)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
async def maybe_async(coro):
|
||||
result = coro
|
||||
if inspect.isawaitable(result):
|
||||
warnings.warn('Using async sessions support is an experimental feature')
|
||||
result = await result
|
||||
return result
|
||||
|
Reference in New Issue
Block a user