Skip to content

Commit 65b5229

Browse files
committed
Use inspect's iscoroutinefunction, not asyncio's
1 parent b057dcb commit 65b5229

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

pyrogram/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import asyncio
2020
import functools
21+
import inspect
2122
import logging
2223
import os
2324
import re
@@ -1025,7 +1026,7 @@ async def get_file(
10251026
offset += limit
10261027

10271028
if progress:
1028-
if asyncio.iscoroutinefunction(progress):
1029+
if inspect.iscoroutinefunction(progress):
10291030
await progress(
10301031
min(offset, file_size) if file_size != 0 else offset,
10311032
file_size,

pyrogram/dispatcher.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

1919
import asyncio
20+
import inspect
2021
import logging
2122
from collections import OrderedDict
2223

@@ -203,7 +204,7 @@ async def handler_worker(self, lock):
203204
continue
204205

205206
try:
206-
if asyncio.iscoroutinefunction(handler.callback):
207+
if inspect.iscoroutinefunction(handler.callback):
207208
await handler.callback(self.client, *args)
208209
else:
209210
await self.loop.run_in_executor(

pyrogram/methods/advanced/save_file.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import asyncio
2020
import functools
21+
import inspect
2122
import io
2223
import logging
2324
import math
@@ -182,7 +183,7 @@ async def worker(session):
182183
file_part += 1
183184

184185
if progress:
185-
if asyncio.iscoroutinefunction(progress):
186+
if inspect.iscoroutinefunction(progress):
186187
await progress(min(file_part * part_size, file_size), file_size, *progress_args)
187188
else:
188189
func = functools.partial(

0 commit comments

Comments
 (0)