-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
asyncio.iscoroutinefunction(<async_generator>.asend) returns False #81371
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
Comments
asyncio.iscoroutinefunction(<async_generator>.__anext__)
asyncio.iscoroutinefunction(<async_generator>.asend)
asyncio.iscoroutinefunction(<async_generator>.athrow)
asyncio.iscoroutinefunction(<async_generator>.aclose) All of these return False, is this the intended behavior? Aren't all of these in fact coroutine functions? |
These functions are not coroutine functions but rather functions which return an awaitable object. You can use |
@kumaraditya303 they are functions that return coroutines - otherwise they could not be used with >>> import asyncio
>>> async def async_generator(): yield
...
>>> asyncio.iscoroutine(async_generator().asend(None))
True
>>> so I think this needs re-opening |
It is not a |
The bug here is with async_generator_asend/athrow
now that Currently async frameworks have specific hacks that require creating a prototypical async generator function and taking a copy of the built in asend/aclose types for inspection |
So how do you propose to fix this? Can you create a PR for this to discuss? |
This PR may fix python#81371
There is now a canonical way to mark a function that is not actually defined with I think the mentioned methods of async generators should probably be marked in the same way, although that might be a bit tricky for methods implemented in C; it could involve some changes to the internal implementation details of |
@kumaraditya303 Hi. Can you explain why aditional bifield in inderlying structures such as |
This will never work properly because in native code we cannot distinguish between a function and a coroutine, regarding adding flags that's just going to complicate things. These aren't the only methods which return coroutine like objects, there can be more in third party code. The proper way to workaround this is to use |
I'm -1 on this, the users should use |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs
The text was updated successfully, but these errors were encountered: