-
-
Notifications
You must be signed in to change notification settings - Fork 367
Closed
Description
>>> from trio.lowlevel import enable_ki_protection
>>> async def foo():
... return
...
>>> @enable_ki_protection
... async def bar():
... return
...
>>> import inspect
>>> inspect.iscoroutinefunction(foo)
True
>>> inspect.iscoroutinefunction(bar)
False
Found when I tried to update coroutine_or_error
in trio/_util.py
to use inspect.iscoroutinefunction
in #2668
Lines 137 to 141 in 3146638
# We can't check iscoroutinefunction(async_fn), because that will fail | |
# for things like functools.partial objects wrapping an async | |
# function. So we have to just call it and then check whether the | |
# return value is a coroutine object. | |
# Note: will not be necessary on python>=3.8, see https://bugs.python.org/issue34890 |
There are also a ton of wrapper/helper methods in tests that un-coroutinefunction-ify functions, which'd need to be modified in order to actually use iscoroutinefunction
in couroutine_or_error
. This means it'd probably also break a bunch of downstream code if coroutine_or_error
was rewritten, but the upside of not having to call the function might mean that it's worth it (after a deprecation period)? That's probably for another issue though.
Metadata
Metadata
Assignees
Labels
No labels