Skip to content
This repository was archived by the owner on Aug 8, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions backoff/_async.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding:utf-8
import datetime
import inspect
import functools
import asyncio
from datetime import timedelta
Expand All @@ -8,7 +9,7 @@


def _ensure_coroutine(coro_or_func):
if asyncio.iscoroutinefunction(coro_or_func):
if inspect.iscoroutinefunction(coro_or_func):
return coro_or_func
else:
@functools.wraps(coro_or_func)
Expand Down Expand Up @@ -47,10 +48,10 @@ def retry_predicate(target, wait_gen, predicate,
on_giveup = _ensure_coroutines(on_giveup)

# Easy to implement, please report if you need this.
assert not asyncio.iscoroutinefunction(max_tries)
assert not asyncio.iscoroutinefunction(jitter)
assert not inspect.iscoroutinefunction(max_tries)
assert not inspect.iscoroutinefunction(jitter)

assert asyncio.iscoroutinefunction(target)
assert inspect.iscoroutinefunction(target)

@functools.wraps(target)
async def retry(*args, **kwargs):
Expand Down Expand Up @@ -124,8 +125,8 @@ def retry_exception(target, wait_gen, exception,
giveup = _ensure_coroutine(giveup)

# Easy to implement, please report if you need this.
assert not asyncio.iscoroutinefunction(max_tries)
assert not asyncio.iscoroutinefunction(jitter)
assert not inspect.iscoroutinefunction(max_tries)
assert not inspect.iscoroutinefunction(jitter)

@functools.wraps(target)
async def retry(*args, **kwargs):
Expand Down
6 changes: 3 additions & 3 deletions backoff/_decorator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding:utf-8
import asyncio
import inspect
import logging
import operator
from typing import Any, Callable, Iterable, Optional, Type, Union
Expand Down Expand Up @@ -98,7 +98,7 @@ def decorate(target):
log_level=giveup_log_level
)

if asyncio.iscoroutinefunction(target):
if inspect.iscoroutinefunction(target):
retry = _async.retry_predicate
else:
retry = _sync.retry_predicate
Expand Down Expand Up @@ -198,7 +198,7 @@ def decorate(target):
log_level=giveup_log_level,
)

if asyncio.iscoroutinefunction(target):
if inspect.iscoroutinefunction(target):
retry = _async.retry_exception
else:
retry = _sync.retry_exception
Expand Down
Loading