本文整理匯總了Python中tornado.platform.asyncio.AsyncIOLoop方法的典型用法代碼示例。如果您正苦於以下問題:Python asyncio.AsyncIOLoop方法的具體用法?Python asyncio.AsyncIOLoop怎麽用?Python asyncio.AsyncIOLoop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tornado.platform.asyncio
的用法示例。
在下文中一共展示了asyncio.AsyncIOLoop方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_new_ioloop
# 需要導入模塊: from tornado.platform import asyncio [as 別名]
# 或者: from tornado.platform.asyncio import AsyncIOLoop [as 別名]
def get_new_ioloop(self):
io_loop = AsyncIOLoop()
asyncio.set_event_loop(io_loop.asyncio_loop)
return io_loop
示例2: configure
# 需要導入模塊: from tornado.platform import asyncio [as 別名]
# 或者: from tornado.platform.asyncio import AsyncIOLoop [as 別名]
def configure(
cls, impl: "Union[None, str, Type[Configurable]]", **kwargs: Any
) -> None:
if asyncio is not None:
from tornado.platform.asyncio import BaseAsyncIOLoop
if isinstance(impl, str):
impl = import_object(impl)
if isinstance(impl, type) and not issubclass(impl, BaseAsyncIOLoop):
raise RuntimeError(
"only AsyncIOLoop is allowed when asyncio is available"
)
super(IOLoop, cls).configure(impl, **kwargs)
示例3: configurable_default
# 需要導入模塊: from tornado.platform import asyncio [as 別名]
# 或者: from tornado.platform.asyncio import AsyncIOLoop [as 別名]
def configurable_default(cls) -> Type[Configurable]:
from tornado.platform.asyncio import AsyncIOLoop
return AsyncIOLoop
示例4: configure
# 需要導入模塊: from tornado.platform import asyncio [as 別名]
# 或者: from tornado.platform.asyncio import AsyncIOLoop [as 別名]
def configure(cls, impl, **kwargs):
if asyncio is not None:
from tornado.platform.asyncio import BaseAsyncIOLoop
if isinstance(impl, (str, unicode_type)):
impl = import_object(impl)
if not issubclass(impl, BaseAsyncIOLoop):
raise RuntimeError(
"only AsyncIOLoop is allowed when asyncio is available")
super(IOLoop, cls).configure(impl, **kwargs)
示例5: configurable_default
# 需要導入模塊: from tornado.platform import asyncio [as 別名]
# 或者: from tornado.platform.asyncio import AsyncIOLoop [as 別名]
def configurable_default(cls):
if asyncio is not None:
from tornado.platform.asyncio import AsyncIOLoop
return AsyncIOLoop
return PollIOLoop
示例6: get_new_ioloop
# 需要導入模塊: from tornado.platform import asyncio [as 別名]
# 或者: from tornado.platform.asyncio import AsyncIOLoop [as 別名]
def get_new_ioloop(self):
io_loop = AsyncIOLoop()
return io_loop
示例7: setUp
# 需要導入模塊: from tornado.platform import asyncio [as 別名]
# 或者: from tornado.platform.asyncio import AsyncIOLoop [as 別名]
def setUp(self):
# Trigger a cleanup of the mapping so we start with a clean slate.
AsyncIOLoop().close()
# If we don't clean up after ourselves other tests may fail on
# py34.
self.orig_policy = asyncio.get_event_loop_policy()
asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
示例8: test_ioloop_close_leak
# 需要導入模塊: from tornado.platform import asyncio [as 別名]
# 或者: from tornado.platform.asyncio import AsyncIOLoop [as 別名]
def test_ioloop_close_leak(self):
orig_count = len(IOLoop._ioloop_for_asyncio)
for i in range(10):
# Create and close an AsyncIOLoop using Tornado interfaces.
loop = AsyncIOLoop()
loop.close()
new_count = len(IOLoop._ioloop_for_asyncio) - orig_count
self.assertEqual(new_count, 0)