|
1 | 1 | # coding:utf-8
|
2 | 2 | import datetime
|
| 3 | +import inspect |
3 | 4 | import functools
|
4 | 5 | import asyncio
|
5 | 6 | from datetime import timedelta
|
|
8 | 9 |
|
9 | 10 |
|
10 | 11 | def _ensure_coroutine(coro_or_func):
|
11 |
| - if asyncio.iscoroutinefunction(coro_or_func): |
| 12 | + if inspect.iscoroutinefunction(coro_or_func): |
12 | 13 | return coro_or_func
|
13 | 14 | else:
|
14 | 15 | @functools.wraps(coro_or_func)
|
@@ -47,10 +48,10 @@ def retry_predicate(target, wait_gen, predicate,
|
47 | 48 | on_giveup = _ensure_coroutines(on_giveup)
|
48 | 49 |
|
49 | 50 | # Easy to implement, please report if you need this.
|
50 |
| - assert not asyncio.iscoroutinefunction(max_tries) |
51 |
| - assert not asyncio.iscoroutinefunction(jitter) |
| 51 | + assert not inspect.iscoroutinefunction(max_tries) |
| 52 | + assert not inspect.iscoroutinefunction(jitter) |
52 | 53 |
|
53 |
| - assert asyncio.iscoroutinefunction(target) |
| 54 | + assert inspect.iscoroutinefunction(target) |
54 | 55 |
|
55 | 56 | @functools.wraps(target)
|
56 | 57 | async def retry(*args, **kwargs):
|
@@ -124,8 +125,8 @@ def retry_exception(target, wait_gen, exception,
|
124 | 125 | giveup = _ensure_coroutine(giveup)
|
125 | 126 |
|
126 | 127 | # Easy to implement, please report if you need this.
|
127 |
| - assert not asyncio.iscoroutinefunction(max_tries) |
128 |
| - assert not asyncio.iscoroutinefunction(jitter) |
| 128 | + assert not inspect.iscoroutinefunction(max_tries) |
| 129 | + assert not inspect.iscoroutinefunction(jitter) |
129 | 130 |
|
130 | 131 | @functools.wraps(target)
|
131 | 132 | async def retry(*args, **kwargs):
|
|
0 commit comments