Skip to content
Ultra fast asyncio event loop.
Python Other
  1. Python 98.5%
  2. Other 1.5%
Branch: master
Clone or download

Latest commit

achimnol and 1st1 fix: Accept path-like objects in subprocess arguments
* Also add subprocess test case using Path object

* uvloop already handles path-like cwd correctly, so I just
  copy-and-pasted the same logic to _init_args() method.

* The standard library uses "isinstance(obj, os.PathLike)" to check
  if an object is path-like, but os.PathLike exists as of Python 3.6.
  Since uvloop needs to support Python 3.5, we should use manual check
  for existence of the __fspath__ attribute.

* According to the official Python documentation:

  - https://docs.python.org/3/library/subprocess.html#subprocess.Popen
    The subprocess.Popen() constructor support path-like objects since
    Python 3.6 on POSIX and since Python 3.8 on Windows.

  - https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.subprocess_exec
    This page does not mention about path-like objects,
    but as of Python 3.8, it DOES support path-like objects.
Latest commit 0d14ec6 Apr 7, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.ci fix Travis macOS build (#325) Mar 24, 2020
.github issue template: Ask if uvloop behaves differently from vanilla asyncio Oct 24, 2019
docs Enforce consistent code style with flake8 Feb 16, 2019
examples/bench prefer PROTOCOL_TLS than PROTOCOL_SSLv23 Oct 22, 2019
tests fix: Accept path-like objects in subprocess arguments May 16, 2020
uvloop fix: Accept path-like objects in subprocess arguments May 16, 2020
vendor Bump libuv to v1.33.1 Oct 24, 2019
.editorconfig Add .editorconfig Oct 22, 2016
.flake8 Enforce consistent code style with flake8 Feb 16, 2019
.gitignore Ignore mypy cache Oct 22, 2019
.gitmodules Switch libuv submodule url to https Feb 3, 2016
.travis.yml travis: Add 3.8 to the mix; drop "sudo" Oct 24, 2019
LICENSE-APACHE Update license files for GH Sep 13, 2017
LICENSE-MIT Dual-license uvloop under MIT and Apache 2.0 Jul 5, 2016
MANIFEST.in Add .flake8 to distribution tarball (fixes: #330) Apr 9, 2020
Makefile Unbreak CI May 30, 2018
README.rst Note that it's recommended to upgrade pip before installing uvloop Oct 25, 2019
performance.png readme: Add a section about uvloop performance May 22, 2016
pytest.ini pytest: Show all warnings Nov 24, 2017
requirements.dev.txt Bump Cython & pyOpenSSL deps to most recent Oct 24, 2019
setup.py updated cython version check Feb 20, 2020

README.rst

https://travis-ci.org/MagicStack/uvloop.svg?branch=master PyPI - Downloads

uvloop is a fast, drop-in replacement of the built-in asyncio event loop. uvloop is implemented in Cython and uses libuv under the hood.

The project documentation can be found here. Please also check out the wiki.

Performance

uvloop makes asyncio 2-4x faster.

performance.png

The above chart shows the performance of an echo server with different message sizes. The sockets benchmark uses loop.sock_recv() and loop.sock_sendall() methods; the streams benchmark uses asyncio high-level streams, created by the asyncio.start_server() function; and the protocol benchmark uses loop.create_server() with a simple echo protocol. Read more about uvloop in a blog post about it.

Installation

uvloop requires Python 3.5 or greater and is available on PyPI. Use pip to install it:

$ pip install uvloop

Note that it is highly recommended to upgrade pip before installing uvloop with:

$ pip install -U pip

Using uvloop

Call uvloop.install() before calling asyncio.run() or manually creating an asyncio event loop:

import asyncio
import uvloop

async def main():
    # Main entry-point.
    ...

uvloop.install()
asyncio.run(main())

Building From Source

To build uvloop, you'll need Python 3.5 or greater:

  1. Clone the repository:

    $ git clone --recursive git@github.com:MagicStack/uvloop.git
    $ cd uvloop
    
  2. Create a virtual environment and activate it:

    $ python3.7 -m venv uvloop-dev
    $ source uvloop-dev/bin/activate
    
  3. Install development dependencies:

    $ pip install -r requirements.dev.txt
    
  4. Build and run tests:

    $ make
    $ make test
    

License

uvloop is dual-licensed under MIT and Apache 2.0 licenses.

You can’t perform that action at this time.