【发布时间】:2017-11-07 09:58:49
【问题描述】:
我是这个框架的新手,正在尝试了解使用一个框架的区别/好处
我可以使用非协同程序的非异步函数来做
def while_naughty():
print("naughty")
loop.call_soon(self.while_naughty)
或
async def naughty():
print("naughty")
task = asyncio.ensure_future(naughty())
我知道 ensure_future 将协程作为参数,我希望了解使用call_soon() 比ensure_future() 更有利的情况。
【问题讨论】:
-
您实际上并没有执行
whily_naughty()未来。你只是把它包起来了。 -
我已经删除了“附加”。请一次只回答一个具体问题,否则您的问题太宽泛了。
标签: python python-3.x asynchronous concurrency python-asyncio