A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/MagicStack/uvloop/wiki below:

Home · MagicStack/uvloop Wiki · GitHub

How to use uvloop in an asyncio application?

Just install the uvloop event policy:

import asyncio
import uvloop
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
How to use uvloop with aiohttp+gunicorn?

You have to use a special gunicorn worker class that aiohttp bundles since 0.22.0:

$ gunicorn ... --worker-class aiohttp.worker.GunicornUVLoopWebWorker

Starting your application this way will automatically make asyncio.get_event_loop() to return a uvloop event loop. There is no need to manually install uvloop policy.

How to use uvloop with Tornado?

Install uvloop event policy before calling AsyncIOMainLoop().install():

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()

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4