2016-05-08 04:30:27 +00:00
|
|
|
User Guide
|
|
|
|
==========
|
|
|
|
|
|
|
|
This section of the documentation provides information about how to use
|
|
|
|
uvloop.
|
|
|
|
|
|
|
|
|
|
|
|
Installation
|
|
|
|
------------
|
|
|
|
|
2021-01-25 01:59:20 +00:00
|
|
|
`uvloop` is available from PyPI. It requires Python 3.7.
|
2016-05-08 04:30:27 +00:00
|
|
|
|
|
|
|
Use pip to install it.
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
|
|
|
$ pip install uvloop
|
|
|
|
|
|
|
|
|
|
|
|
Using uvloop
|
|
|
|
------------
|
|
|
|
|
|
|
|
To make asyncio use the event loop provided by `uvloop`, you install the
|
|
|
|
`uvloop` event loop policy:
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
import uvloop
|
|
|
|
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
|
|
|
|
|
|
|
|
|
|
|
Alternatively, you can create an instance of the loop manually, using:
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
import uvloop
|
|
|
|
loop = uvloop.new_event_loop()
|
|
|
|
asyncio.set_event_loop(loop)
|