Use iscoroutinefunction from inspect not asyncio#359
Conversation
Python 3.14 will deprecate asyncio.iscoroutinefunction: python/cpython#122875 inspect.iscoroutinefunction exists since 3.5 and our baseline is 3.8, so we can just use it unconditionally. Using a wrapper with @asyncio.coroutine in __get__ wasn't necessary (the future from asyncio.ensure_future is awaitable, and the wrapper doesn't do anything asynchronous), so the logic can be simplified to just call asyncio.ensure_future (to schedule the task and store the result when it's available).
|
This is a rebase of #267 , but it turns out to be much simpler against 2.0.1. Skipping test_coroutine_cached_property.py as the original did no longer appears to be necessary - arguably that test could now be removed as we're targeting a 3.8 baseline, but it seems like that could be a separate PR. @encukou for info, I've kept you as the author of this but can change it to me if you don't want your name on it any more :) |
|
Pls, let's merge this. Python 3.14 is out |
|
Just in case folks don't know, the standard library functools has a cached_property implementation since 3.8. So if your baseline is 3.8 or higher you can just switch to that and forget about this problem. If you still have < 3.8 as a baseline for some reason (koff koff RHEL), you can do: |
Python 3.14 will deprecate asyncio.iscoroutinefunction: python/cpython#122875
inspect.iscoroutinefunction exists since 3.5 and our baseline is 3.8, so we can just use it unconditionally.
Using a wrapper with @asyncio.coroutine in get wasn't necessary (the future from asyncio.ensure_future is awaitable, and the wrapper doesn't do anything asynchronous), so the logic can be simplified to just call asyncio.ensure_future (to schedule the task and store the result when it's available).