2024-04-18 07:47:39 发布
网友
请考虑以下功能:
def test(): yield 1
asyncio.iscoroutine()方法将返回方法test()的True。另一件需要注意的事情是inspect.iscoroutine()将返回False。你知道吗
asyncio.iscoroutine()
test()
True
inspect.iscoroutine()
False
为什么asyncio认为这是一个协同程序?不管怎样,似乎其中一个弄错了。你知道吗
asyncio
这看起来像是新的python3.7asyncio文档中的一个文档错误。在提出问题和回答这个问题时,new docs说
Return True if obj is a coroutine object.This method is different from inspect.iscoroutine() because it returns True for generator-based coroutines decorated with @coroutine.
Return True if obj is a coroutine object.
This method is different from inspect.iscoroutine() because it returns True for generator-based coroutines decorated with @coroutine.
当old docs说
Return True if obj is a coroutine object, which may be based on a generator or an async def coroutine.
旧文档是正确的;asyncio.iscoroutine认为任何生成器对象都是协同程序,而不仅仅是由@coroutine修饰的生成器函数创建的。你知道吗
asyncio.iscoroutine
@coroutine
在发问者的issue report之后,文档被updated从异步.iscoroutine文件。我会贴一张存档.org显示旧文本的链接,但是存档.org没有存档该版本。不过,您仍然可以在github修订历史或我刚刚链接的提交中看到旧文本。你知道吗
这看起来像是新的python3.7asyncio文档中的一个文档错误。在提出问题和回答这个问题时,new docs说
当old docs说
旧文档是正确的;
asyncio.iscoroutine
认为任何生成器对象都是协同程序,而不仅仅是由@coroutine
修饰的生成器函数创建的。你知道吗在发问者的issue report之后,文档被updated从异步.iscoroutine文件。我会贴一张存档.org显示旧文本的链接,但是存档.org没有存档该版本。不过,您仍然可以在github修订历史或我刚刚链接的提交中看到旧文本。你知道吗
相关问题 更多 >
编程相关推荐