Uvloop: Feature request: add support for Tornado ioloop

Created on 3 Jul 2016  路  3Comments  路  Source: MagicStack/uvloop

uvloop targets asyncio specifically but given that Tornado _can_ use asyncio as the main event loop [1] [2] it looks like integrating the 3 (tornado + asyncio loop + uvloop) could be possible, and perhaps also fairly easily.

I haven't looked into uvloop code specifically but given that the tornado -> asyncio loop bridge is already in place in tornado's code, such an integration could already be possible in principle, in which case the proposal is to investigate how to "enable it" and document it (possibly in both projects).

[1] http://www.tornadoweb.org/en/stable/asyncio.html
[2] https://github.com/MagicStack/uvloop/issues/9

question

Most helpful comment

From the looks of it, all you need to do is to set up uvloop asyncio policy before installing AsyncIOMainLoop:

from tornado.platform.asyncio import AsyncIOMainLoop
import asyncio
import uvloop

asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
AsyncIOMainLoop().install()
asyncio.get_event_loop().run_forever()

Please check if that works.

All 3 comments

From the looks of it, all you need to do is to set up uvloop asyncio policy before installing AsyncIOMainLoop:

from tornado.platform.asyncio import AsyncIOMainLoop
import asyncio
import uvloop

asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
AsyncIOMainLoop().install()
asyncio.get_event_loop().run_forever()

Please check if that works.

Yes, it looks like that just works.

Thank you Ben for checking that. Closing this issue now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scottruss picture scottruss  路  4Comments

spumer picture spumer  路  4Comments

yope picture yope  路  10Comments

ojii picture ojii  路  6Comments

gaby picture gaby  路  4Comments