Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use inspect.iscoroutinefunction instead of asyncio.iscoroutinefunction to avoid Python 3.14 deprecation warning #220

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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