Use inspect's iscoroutinefunction, not asyncio's

This commit is contained in:
Dan 2020-08-25 09:32:39 +02:00
parent b057dcb39d
commit 65b5229fe8
3 changed files with 6 additions and 3 deletions

View File

@ -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,

View File

@ -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(

View File

@ -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(