mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Use inspect's iscoroutinefunction, not asyncio's
This commit is contained in:
parent
b057dcb39d
commit
65b5229fe8
@ -18,6 +18,7 @@
|
||||
|
||||
import asyncio
|
||||
import functools
|
||||
import inspect
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
@ -1025,7 +1026,7 @@ class Client(Methods, Scaffold):
|
||||
offset += limit
|
||||
|
||||
if progress:
|
||||
if asyncio.iscoroutinefunction(progress):
|
||||
if inspect.iscoroutinefunction(progress):
|
||||
await progress(
|
||||
min(offset, file_size) if file_size != 0 else offset,
|
||||
file_size,
|
||||
|
@ -17,6 +17,7 @@
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import asyncio
|
||||
import inspect
|
||||
import logging
|
||||
from collections import OrderedDict
|
||||
|
||||
@ -203,7 +204,7 @@ class Dispatcher:
|
||||
continue
|
||||
|
||||
try:
|
||||
if asyncio.iscoroutinefunction(handler.callback):
|
||||
if inspect.iscoroutinefunction(handler.callback):
|
||||
await handler.callback(self.client, *args)
|
||||
else:
|
||||
await self.loop.run_in_executor(
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
import asyncio
|
||||
import functools
|
||||
import inspect
|
||||
import io
|
||||
import logging
|
||||
import math
|
||||
@ -182,7 +183,7 @@ class SaveFile(Scaffold):
|
||||
file_part += 1
|
||||
|
||||
if progress:
|
||||
if asyncio.iscoroutinefunction(progress):
|
||||
if inspect.iscoroutinefunction(progress):
|
||||
await progress(min(file_part * part_size, file_size), file_size, *progress_args)
|
||||
else:
|
||||
func = functools.partial(
|
||||
|
Loading…
Reference in New Issue
Block a user