mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
gh-122858: Deprecate asyncio.iscoroutinefunction (#122875)
Deprecate `asyncio.iscoroutinefunction` in favor of `inspect.iscoroutinefunction`. Co-authored-by: Kumar Aditya <kumaraditya@python.org>
This commit is contained in:
parent
3aaed083a3
commit
bc9d92c679
10 changed files with 27 additions and 8 deletions
|
|
@ -837,7 +837,7 @@ class BaseEventLoop(events.AbstractEventLoop):
|
|||
|
||||
def _check_callback(self, callback, method):
|
||||
if (coroutines.iscoroutine(callback) or
|
||||
coroutines.iscoroutinefunction(callback)):
|
||||
coroutines._iscoroutinefunction(callback)):
|
||||
raise TypeError(
|
||||
f"coroutines cannot be used with {method}()")
|
||||
if not callable(callback):
|
||||
|
|
|
|||
|
|
@ -18,7 +18,16 @@ _is_coroutine = object()
|
|||
|
||||
|
||||
def iscoroutinefunction(func):
|
||||
import warnings
|
||||
"""Return True if func is a decorated coroutine function."""
|
||||
warnings._deprecated("asyncio.iscoroutinefunction",
|
||||
f"{warnings._DEPRECATED_MSG}; "
|
||||
"use inspect.iscoroutinefunction() instead",
|
||||
remove=(3,16))
|
||||
return _iscoroutinefunction(func)
|
||||
|
||||
|
||||
def _iscoroutinefunction(func):
|
||||
return (inspect.iscoroutinefunction(func) or
|
||||
getattr(func, '_is_coroutine', None) is _is_coroutine)
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
|
|||
Raise RuntimeError if there is a problem setting up the handler.
|
||||
"""
|
||||
if (coroutines.iscoroutine(callback) or
|
||||
coroutines.iscoroutinefunction(callback)):
|
||||
coroutines._iscoroutinefunction(callback)):
|
||||
raise TypeError("coroutines cannot be used "
|
||||
"with add_signal_handler()")
|
||||
self._check_signal(sig)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue