ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、视频、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
### Navigation - [index](# "General Index") - [modules](# "Python Module Index") | - [next](# "tornado.platform.caresresolver — Asynchronous DNS Resolver using C-Ares") | - [previous](# "tornado.wsgi — Interoperability with other Python frameworks and servers") | - [Tornado 4.4.dev1 documentation](#) » - [Integration with other services](#) » # `tornado.platform.asyncio` — Bridge between `asyncio` and Tornado Bridges between the [`asyncio`](https://docs.python.org/3.4/library/asyncio.html#module-asyncio "(in Python v3.4)") [https://docs.python.org/3.4/library/asyncio.html#module-asyncio] module and Tornado IOLoop. New in version 3.2. This module integrates Tornado with the `asyncio` module introducedin Python 3.4 (and available [as a separate download](https://pypi.python.org/pypi/asyncio) [https://pypi.python.org/pypi/asyncio] for Python 3.3). This makesit possible to combine the two libraries on the same event loop. Most applications should use [`AsyncIOMainLoop`](# "tornado.platform.asyncio.AsyncIOMainLoop") to run Tornado on thedefault `asyncio` event loop. Applications that need to run eventloops on multiple threads may use [`AsyncIOLoop`](# "tornado.platform.asyncio.AsyncIOLoop") to create multipleloops. Note Tornado requires the [`add_reader`](https://docs.python.org/3.4/library/asyncio-eventloop.html#asyncio.BaseEventLoop.add_reader "(in Python v3.4)") [https://docs.python.org/3.4/library/asyncio-eventloop.html#asyncio.BaseEventLoop.add_reader] family of methods,so it is not compatible with the [`ProactorEventLoop`](https://docs.python.org/3.4/library/asyncio-eventloops.html#asyncio.ProactorEventLoop "(in Python v3.4)") [https://docs.python.org/3.4/library/asyncio-eventloops.html#asyncio.ProactorEventLoop] on Windows.Use the [`SelectorEventLoop`](https://docs.python.org/3.4/library/asyncio-eventloops.html#asyncio.SelectorEventLoop "(in Python v3.4)") [https://docs.python.org/3.4/library/asyncio-eventloops.html#asyncio.SelectorEventLoop] instead. *class *`tornado.platform.asyncio.``AsyncIOMainLoop`[[source]](#) `AsyncIOMainLoop` creates an [`IOLoop`](# "tornado.ioloop.IOLoop") that corresponds to thecurrent `asyncio` event loop (i.e. the one returned by`asyncio.get_event_loop()`). Recommended usage: ~~~ from tornado.platform.asyncio import AsyncIOMainLoop import asyncio AsyncIOMainLoop().install() asyncio.get_event_loop().run_forever() ~~~ *class *`tornado.platform.asyncio.``AsyncIOLoop`[[source]](#) `AsyncIOLoop` is an [`IOLoop`](# "tornado.ioloop.IOLoop") that runs on an `asyncio` event loop.This class follows the usual Tornado semantics for creating new`IOLoops`; these loops are not necessarily related to the`asyncio` default event loop. Recommended usage: ~~~ from tornado.ioloop import IOLoop IOLoop.configure('tornado.platform.asyncio.AsyncIOLoop') IOLoop.current().start() ~~~ Each `AsyncIOLoop` creates a new `asyncio.EventLoop`; this objectcan be accessed with the `asyncio_loop` attribute. `tornado.platform.asyncio.``to_tornado_future`(*asyncio_future*)[[source]](#) Convert an [`asyncio.Future`](https://docs.python.org/3.4/library/asyncio-task.html#asyncio.Future "(in Python v3.4)") [https://docs.python.org/3.4/library/asyncio-task.html#asyncio.Future] to a [`tornado.concurrent.Future`](# "tornado.concurrent.Future"). New in version 4.1. `tornado.platform.asyncio.``to_asyncio_future`(*tornado_future*)[[source]](#) Convert a Tornado yieldable object to an [`asyncio.Future`](https://docs.python.org/3.4/library/asyncio-task.html#asyncio.Future "(in Python v3.4)") [https://docs.python.org/3.4/library/asyncio-task.html#asyncio.Future]. New in version 4.1. Changed in version 4.3: Now accepts any yieldable object, not just[`tornado.concurrent.Future`](# "tornado.concurrent.Future"). © Copyright 2009-2016, The Tornado Authors. Created using [Sphinx](http://sphinx-doc.org/) 1.3.5.