Код: Выделить всё
import asyncio
async def coro_function():
return 2 + 2
async def get():
return await coro_function()
print(asyncio.iscoroutinefunction(get))
loop = asyncio.get_event_loop()
a1 = loop.create_task(get)
loop.run_until_complete(a1)
Код: Выделить всё
True
Traceback (most recent call last):
File "a.py", line 13, in
a1 = loop.create_task(get)
File "/home/alie/anaconda3/lib/python3.7/asyncio/base_events.py", line 405, in create_task
task = tasks.Task(coro, loop=self)
TypeError: a coroutine was expected, got
Подробнее здесь: https://stackoverflow.com/questions/639 ... s-expected
Мобильная версия