Hi, Is this pattern
def foo():
return bar()
async def bar():
await <whatever>
async def async_main():
await foo()
considered to be valid?
The reason I'm asking is that some code out there likes to accept a
might-be-a-coroutine-function argument, using
def run_callback(fn):
if iscoroutinefunction(fn):
res = await fn()
else:
res = fn()
instead of
def run_callback(fn):
res = fn()
if iscoroutine(res):
res = await res()
The former obviously breaks when somebody combines these idioms and calls
run_callback(foo)
but I can't help but wonder whether the latter use might be deprecated, or
even warned about, in the future and/or with non-CPython implementations.
--
-- Matthias Urlichs
signature.asc
Description: Digital signature
_______________________________________________ Python-Dev mailing list [email protected] https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
