[issue38225] iscoroutinefunction broken with cython - allow tagging of functions as async?

Stefan Behnel report at bugs.python.org
Fri Sep 20 00:23:03 EDT 2019


Stefan Behnel <stefan_ml at behnel.de> added the comment:

My usual first reaction is: "if you need to find out whether the return value of a callable will be an Awaitable or not, without calling it, then you're probably doing something wrong in your design".

However,
a) there is code that tries this already (and it falls short in various ways while trying)
b) asyncio has a function `iscoroutinefunction` which *seems* to fulfil this need but does not achieve it (because not everything that returns an Awaitable is a "coroutine function")
c) asyncio has an internal protocol for marking things as "is a coroutine", which comes close to but isn't "returns an Awaitable when called"

So – should there be an official protocol for marking callables as returning an Awaitable? Should we look at annotations for that? Anything else? Or do we consider this intention inherently flawed?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38225>
_______________________________________


More information about the Python-bugs-list mailing list