我知道,自5.0以来,龙卷风的ioloop由asyncio处理,实际上,我使用tornado.ioloop.IOloop.current()
所获得的循环默认为asyncio循环。我的问题是如何以适当的方式访问异步循环本身。例如,我想在asyncio循环上使用loop.create_future()
方法,但是龙卷风将循环包裹起来,并且它没有此方法。
目前,我的工作是在需要异步方法时才调用asyncio.get_event_loop()
(因为文档指出这两个循环确实是相同的)。我不确定这是否是正确的方法,因为现在我对具有不同接口的同一ioloop有不同的引用,而我使用了所需的接口。这有点混乱和混乱。
有更好的方法吗?我可以告诉龙卷风给我asyncio循环而不包装它吗?还是可以使用龙卷风创建的IOloop
以某种方式访问这些方法?
编辑:
https://www.tornadoweb.org/en/stable/ioloop.html#module-tornado.ioloop在这里指出:
应用程序可以直接使用IOLoop接口或基础asyncio事件循环
我对后者感兴趣,但是我找不到直接访问它的说明。
答案 0 :(得分:1)
asyncio.get_event_loop()
;无需使用(未记录的)asyncio_loop
属性。这是所有非特定于龙卷风的异步代码如何获取事件循环的方法。
答案 1 :(得分:0)
我终于找到了办法。因此,龙卷风创建的ioloop的类型为select col1,
, case when col2 in ('Verifying', 'Verified') then 'Verification_Stage'
when col2 in ('Reviewing', 'Reviewed') then 'Reviewing_Stage'
when col2 in ('Analyzing', 'Analyzed') then 'Analyzing_Stage'
else col2 end
, sum(col3)
, sum(col4)
from tableA
group by col1,
case when col2 in ('Verifying', 'Verified') then 'Verification_Stage'
when col2 in ('Reviewing', 'Reviewed') then 'Reviewing_Stage'
when col2 in ('Analyzing', 'Analyzed') then 'Analyzing_Stage'
else col2 end
。我去了源代码,它的基类是AsyncIOMainLoop
,在该类中有一个名为BaseAsyncIOLoop
有了这个,我终于能够使用asyncio循环。 (asyncio_loop
)