freshcrate
Skin:/
Home > Frameworks > uvloop

uvloop

Fast implementation of asyncio event loop on top of libuv

Why this rank:Strong adoptionRelease freshnessHealthy release cadence

Description

.. image:: https://img.shields.io/github/actions/workflow/status/MagicStack/uvloop/tests.yml?branch=master :target: https://github.com/MagicStack/uvloop/actions/workflows/tests.yml?query=branch%3Amaster .. image:: https://img.shields.io/pypi/v/uvloop.svg :target: https://pypi.python.org/pypi/uvloop .. image:: https://pepy.tech/badge/uvloop :target: https://pepy.tech/project/uvloop :alt: 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 <http://uvloop.readthedocs.org/>`_. Please also check out the `wiki <https://github.com/MagicStack/uvloop/wiki>`_. Performance ----------- uvloop makes asyncio 2-4x faster. .. image:: https://raw.githubusercontent.com/MagicStack/uvloop/master/performance.png :target: http://magic.io/blog/uvloop-blazing-fast-python-networking/ 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 <http://magic.io/blog/uvloop-blazing-fast-python-networking/>`_ about it. Installation ------------ uvloop requires Python 3.8 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 ------------ As of uvloop 0.18, the preferred way of using it is via the ``uvloop.run()`` helper function: .. code:: python import uvloop async def main(): # Main entry-point. ... uvloop.run(main()) ``uvloop.run()`` works by simply configuring ``asyncio.run()`` to use uvloop, passing all of the arguments to it, such as ``debug``, e.g. ``uvloop.run(main(), debug=True)``. With Python 3.11 and earlier the following alternative snippet can be used: .. code:: python import asyncio import sys import uvloop async def main(): # Main entry-point. ... if sys.version_info >= (3, 11): with asyncio.Runner(loop_factory=uvloop.new_event_loop) as runner: runner.run(main()) else: uvloop.install() asyncio.run(main()) Building From Source -------------------- To build uvloop, you'll need Python 3.8 or greater: 1. Clone the repository: .. code:: $ git clone --recursive git@github.com:MagicStack/uvloop.git $ cd uvloop 2. Create a virtual environment and activate it: .. code:: $ python3 -m venv uvloop-dev $ source uvloop-dev/bin/activate 3. Install development dependencies: .. code:: $ pip install -e .[dev] 4. Build and run tests: .. code:: $ make $ make test License ------- uvloop is dual-licensed under MIT and Apache 2.0 licenses.

Release History

VersionChangesUrgencyDate
0.22.1Imported from PyPI (0.22.1)Low4/21/2026
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.1This is identical to 0.22.0, re-ran with CI fixesLow10/16/2025
v0.22.0Changes ======= * Fixes for Python 3.14 (#638) (by @graingert @hroncok @paulocheque @fantix in 46456b6a for #637) * Add free-threading support (#693) (by @kumaraditya303 in 286b3707 for #642) Fixes ===== * Use Cython `enum` for `__PREALLOCED_BUFS` (#634) (by @jakirkham in 7bb12a17 for #634) * test: fix getaddrinfo test (#663) (by @fantix in 56807922 for #663) * test: fix task name for Python 3.13.3/3.14 (#662) (by @cjwatson in 96b7ed31 for #662)Low10/16/2025
v0.21.0Changes ======= * Add cleanup_socket param on create_unix_server() (#623) (by @fantix in d6114d2) Fixes ===== * Use cythonized SO_REUSEPORT rather than the unwrapped native one. (#609) (by @ptribble in 4083a94e for #550) * UDP errors should result in protocol.error_received (#601) (by @jensbjorgensen in 3c3bbeff) * Updates for Cython3 (#587) (by @alan-brooks in 3fba9fab for #587) * Test with Python 3.13 (#610) (by @edgarrmondragon in fb5a139)Low10/14/2024
v0.21.0beta1Release v0.21.0beta1Low9/3/2024
v0.20.0Changes ======= * Upgrade libuv to v1.48.0 (#600) (by @niklasr22 @fantix in 77778525 for #596 #615) Fixes ===== * Fix test_create_server_4 with Python 3.12.5 (#614) (by @shadchin in 62f92393) * Use len(os.sched_getaffinity(0)) instead of os.cpu_count() (#591) (by @avkarenow in c8531c24 for #591) * Inline _Py_RestoreSignals() from CPython (#604) (by @befeleme in 8511ba1f for #603)Low8/15/2024
v0.19.0Changes ======= * Drop support of Python 3.7 and update CI (#578) (by @fantix in ee5ad26a for #578) Fixes ===== * Restore uvloop.new_event_loop and other missing uvloop members to typing (#573) (by @graingert in 5c500ee2 for #573) * Fix docstring of loop.shutdown_default_executor (#535) (by @Gelbpunkt in 919da567 for #535) * Fix CI status badge (#522) (by @shuuji3 in 0e9ff6cd for #522)Low10/22/2023
v0.18.0Fixes ===== * CI fixes (#520, #553) (by @altendky in 7783f1c5, @dulmandakh in 1dd40f17) * Make extract_stack resilient to lacking frames. (#563) (by @jhance in 06876434 for #563) * Port uvloop to Python 3.12 (#570) (by @1st1, @fantix in 9f82bd74 for #569)Low10/13/2023
v0.17.0This release adds Python 3.11 support, updates bundled libuv to 1.43.0 and fixes a handful of issues. Changes ======= * Expose uv_loop_t pointer for integration with other C-extensions (#310) (by @pranavtbhat in b332eb85 for #310) * Support python 3.11+ (#473) (by @zeroday0619 in 8e42921d for #473) * Expose libuv uv_fs_event functionality (#474) (by @jensbjorgensen @fantix in 74d381e8 for #474) * Activate debug mode when `-X dev` is used (by @jack1142 in 637a77a3) Low9/14/2022
v0.16.0This release adds Python 3.10 support, updates bundled libuv to 1.42.0 and fixes a handful of issues. Changes ======= * Python 3.10 support (#432) (by @elprans in 2519e2df for #432) * Bump vendored libuv to 1.42.0 (#433) (by @elprans in a62f7818 for #433) * Use cibuildwheel to build wheels (#435) (by @elprans in 20febe0b for #435) * Add support for `<timer handle>.when()` (by Jens Jorgensen in 62b2af9c) Fixes ===== * Fix ref issue when protocol is in Cython (by @fantix in 70cafcLow8/10/2021
v0.15.3# Bug Fixes * SSL: schedule first data after waiter wakeup (by @fantix in 0df12282) * Fix a possible race condition in sslproto test (by @fantix in 2e71c4c2 for #412) * Fix `call_soon_threadsafe` thread safety (by @fantix and @hehaha in 6387a4e4 for #408)Low7/13/2021
v0.15.2# Bug Fixes * Add `python_requires` in `setup.py` to fix dependency resolution issues (by @graingert in c808a663)Low2/19/2021
v0.15.1# Bug Fixes * Fix a segfault issue when a Cython protocol is de-referencing itself from `Context.run()` callbacks (by @fantix in 70cafc82)Low2/15/2021
v0.15.0# New Features * Add name keyword argument to `loop.create_task()` (by @fantix in d51ce367 for #309) * Add typing support (by @bryanforbes in 9426e2b1, for #358) # Bug Fixes * SSL: many improvements (by @fantix in 6476aad6, 8beacd26, 98e113ee, ae44ec2d, @asvetlov in 9bc4a204) * Fix `KeyboardInterrupt` handling logic (by @1st1 in c32c7039 for #295, @jack1142 in 8c471f82 for #337) * Python 3.8/3.9 compatibility fixes, drop support for 3.5/3.6 (by @jack1142 in 28702Low2/10/2021
v0.14.0# New Features * Add support for Python 3.8. (by @1st1 in 5f48dab8, 51636f7b) # Bug Fixes * Multiple fixes in the SSL/TLS layer. (by @fantix in 82104fb6 for #263, 7fcbfed1 for #255, e6fd6377) * Restore `signal.wakeup_fd` after the event loop is closed. (by @vladima in 48d376d3, @1st1 in d76d9827) * Handle large timeouts in `loop.call_later()`. (by @1st1 in 1a0d6578 for #259) * Fix possible feezing of uvloop on `os.fork`. (by @grungy-ado in fde5d14f) * Better hLow11/5/2019
v0.14.0rc2### This is the **second** release candidate. ### See the full list of updates in [0.14.0rc1 release notes](https://github.com/MagicStack/uvloop/releases/tag/v0.14.0rc1). # RC2 Bug Fixes * Fix libuv not waking up on SIGINT. (by @1st1 in c32c703 for #295) * Fix SSL proto to better handle EOF. (by @fantix in 6476aad)Low10/29/2019
v0.14.0rc1# New Features * Add support for Python 3.8. (by @1st1 in 5f48dab8, 51636f7b) # Bug Fixes * Multiple fixes in the SSL/TLS layer. (by @fantix in 82104fb6 for #263, 7fcbfed1 for #255) * Restore `signal.wakeup_fd` after the event loop is closed. (by @vladima in 48d376d3) * Handle large timeouts in `loop.call_later()`. (by @1st1 in 1a0d6578 for #259) * Fix possible feezing of uvloop on `os.fork`. (by @grungy-ado in fde5d14f) * Better handle Unix sockets for datagrLow10/25/2019
v0.13.0# New Features * Implement `Server.start_serving()` and related APIs. (by @jlaine in 7a4f00a3) * Make `Server` an asynchronous context manager. (by @jlaine in d6c67e7a for #221) # Performance * Start using high-performance `uv_udp_t` handle. This should result in a significantly faster UDP support. (by @1st1 in c2b65bc8) * Make address validation faster in `udp.sendto()`. (by @1st1 in 46c5e9eb) # Misc * `OSError` is no longer logged by Transports. This maLow8/14/2019
v0.13.0rc1 # New Features * Implement `Server.start_serving()` and related APIs. (by @jlaine in 7a4f00a3) * Make `Server` an asynchronous context manager. (by @jlaine in d6c67e7a for #221) # Performance * Start using high-performance `uv_udp_t` handle. This should result in a significantly faster UDP support. (by @1st1 in c2b65bc8) * Make address validation faster in `udp.sendto()`. (by @1st1 in 46c5e9eb) # Build * Upgrade to libuv `v1.28.0`. *This is a minimumLow4/25/2019
v0.12.2# Bug Fixes * Fix circular references in SSL implementation to reduce the need for GC. (by @fantix in 3070ec85) * Fix a memory leak in `call_later()` and `call_at()`. The leak occurred when a callback argument had a reference to the event loop. (by @1st1 in 1a5dbc28 for #239) * Fix compilation warnings. (by @JelleZijlstra in d9a111be) * Round (instead of flooring) delay in `call_later()`. This ensures that the callback is never called slightly *before* the speLow3/20/2019
v0.12.1# Bug Fixes * Fix a circular references case in SSL implementation. (by @fantix in a2e0dd8e for #220) * Cleanup references to callbacks in canceled callback handles. This removes potential reference cycles between bound methods and cancelled `Handle` / `TimerHandle` objects. (by @1st1 in f0a945df)Low2/12/2019
v0.12.0# New Features * New SSL implementation. The new implementation is faster and and more complete, and might become the default SSL implementation in asyncio 3.9. See the linked issue for more details. (by @fantix in 9cba7493 for #158, #176) * New `uvloop.install()` helper function. Instead of ```python import asyncio import uvloop asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) ``` it is now possible to simply write ```python imporLow1/21/2019
v0.12.0rc1# New Features * New SSL implementation. The new implementation is faster and and more complete, and will become the default SSL implementation in asyncio 3.8. This is a significant change that warrants a release candidate to make sure it is tested properly. See the linked issue for more details. (by @fantix in 9cba7493 for #158, #176) * New `uvloop.install()` helper function. Instead of ```python import asyncio import uvloop asyncio.set_event_loop_poLow11/1/2018
v0.11.3# Bug Fixes * Use new `PyOS_BeforeFork` and `PyOS_AfterFork_*` 3.7 APIs when available (by @1st1 in 75e7c32a) * Fix async generators finalization to function correctly in debug mode (by @1st1 in dcbb1f4f for #200) * Pass `backlog` to `loop.create_unix_server()` when a server is created via `loop.create_server(sock=unix_sock, backlog=backlog)`. (by @hikoz in 40ad257b) * Don't raise "requires a DNS lookup" error on Unix Domain Socket (#204) (by @pax0r in 9fc3ca2a for #2Low10/31/2018
v0.11.2# Bug Fixes * Fix a memory leak related to contextvars support. (by @hellysmile and @1st1 in 2ddb4807 for #192)Low8/7/2018
v0.10.3**Note:** this is a bugfix release for 0.10.x branch. It's recommended to upgrade to 0.11.x. # Bug Fixes * Fix a memory leak in contextvars support. (https://github.com/MagicStack/uvloop/pull/192 for more details)Low8/7/2018
v0.11.1# Bug Fixes * Fix server to shutdown when alive connections exist (by @ciscorn in 5f71e29f for #180 in PR #181) * Fix a few bugs and crashes in UDP layer (by @1st1 in e0b5ea03, 5eef2d5f for #190) * Fix FD leakage if spawning a subprocess fails (by @1st1 in 4f6621eb for #185, #186) * Fix libuv process handles leak when `uv_spawn()` fails (by @1st1 in 92ea5179 for #187) Low8/2/2018
v0.11.0# New Features * Implement support for `BufferedProtocol`. (by @1st1 in a959f274, 76b34bef, f9c43937) * Implement `loop.start_tls()`. (by @1st1 in 622ed9c5) * Add `Server.get_loop()`. (by @1st1 in 6a42f841) # Bug Fixes * Fix Server to wait in wait_closed() until all transports are done. (by @1st1 in 124e981b) * SSLTransport.abort() should mark the transport as closed. (by @1st1 in 4d6621f7) * Fix 3.7 32bit builds. (by @1st1 in a68f3c9a, b5b4abb1 for #172)Low7/5/2018
v0.10.2# Bug Fixes * Use a proper type for the thread indent (fixes 32-bit build for 3.7.) (by @1st1 in 700582a9 for #172) * Fix cancellation race in `loop.sock_recv()` and `loop.sock_recv_into()` methods. (by @andr-04 and @1st1 in 298851bf for #169) * Sync SSL error messages with CPython's SSL implementation. (by @1st1 in c3aeff2a) * Fix `SSLTransport.abort()` to mark the transport as closed. (by @1st1 in ba25d8be) * Detect if libuv submodule has not been checked out in `seLow6/25/2018
v0.10.1Bug Fixes ======= * Bump Cython from 0.28.2 to 0.28.3. (by @1st1 in 5044d240) * Increase default SSL handshake timeout to 60 seconds. (by @1st1 in 70c332cf, fixes #161) * Add `ssl_handshake_timeout` parameter to `loop.create_connection()`, `loop.create_server()`, `loop.create_unix_connection()`, `loop.create_unix_server()`, `loop.connect_accepted_socket()`. (by @1st1 in 68dd7337, addresses #161) * Consistently close transports if create_server/create_connection/etc Low6/1/2018
v0.10.0New Features ============ * Initial support for Python 3.7. (by @pfreixes in c3a5ec8e for #138) * Implement PEP 567 support (contextvars module) for Python 3.7. (by @1st1 in 2a4fab44, 878e4163, and b2bdaae3 for #155) * Add uvloop's own version of `asyncio/sslproto.py`. SSL is now ~50% faster. (by @1st1 in 4d912643) * Convert Future-returning loop methods to coroutines to match asyncio 3.7. (by @1st1 in 7384b22f) * Allow file objects to be passed to `loop.subprocess*()Low5/30/2018
v0.9.1* Stop using malloc for `uv_request*` handlers. * Fix `loop.add_reader()`, `loop.add_writer()`, `loop.remove_reader()`, and `loop.remove_writer()` to better track socket objects. * Fix `loop.sock_recv()`, `loop.sock_sendall()`, `loop.sock_recv_into()`, and `loop.sock_connect()` to correctly handle `Task.cancel()`. * Better handle immediate cancellation of `loop.create_connection()`. * Make unit tests stricter: ensure `loop.call_exception_handler()` does not get called, unlesLow11/29/2017
v0.9.0## TCP & UDP Transports * `transport.get_extra_info('socket')` now returns a socket-like object. It supports socket methods like `setsockopts()`, but prohibits `send()`, `recv()`, `close()` and any other calls that can interfere with the transport that ultimately owns this file descriptor. * `TCP_NODELAY` is used by default for all TCP connections. * Make `Transport.resume_reading()` and `pause_reading()` idempotent. This will match asyncio in Python 3.7. Issue #93. Low11/27/2017
v0.8.1Release v0.8.1Low9/12/2017
v0.8.0Release v0.8.0Low2/10/2017
v0.7.0Release v0.7.0Low12/24/2016
v0.6.7Release v0.6.7Low11/29/2016
v0.6.5Release v0.6.5Low11/11/2016
v0.6.1Release v0.6.1Low11/10/2016
v0.5.4Release v0.5.4Low10/5/2016
v0.5.3Release v0.5.3Low8/24/2016
v0.5.0Release v0.5.0Low7/19/2016
v0.4.34Release v0.4.34Low7/12/2016
v0.4.33Release v0.4.33Low7/5/2016
v0.4.32Release v0.4.32Low7/4/2016
v0.4.31Release v0.4.31Low6/28/2016
v0.4.30Release v0.4.30Low6/9/2016
v0.4.29Release v0.4.29Low5/29/2016
v0.4.28Release v0.4.28Low5/23/2016
v0.4.27Release v0.4.27Low5/23/2016
v0.4.26Release v0.4.26Low5/21/2016

Dependencies & License Audit

Loading dependencies...

Similar Packages

aiosmtplibasyncio SMTP clientv5.1.1
python-socksProxy (SOCKS4, SOCKS5, HTTP CONNECT) client for Python2.8.1
txaioCompatibility API between asyncio/Twisted/Trollius25.12.2
autobahnWebSocket client & server library, WAMP real-time framework25.12.2
greenbackReenter an async event loop from synchronous code1.3.0

More from pypi

markitdownUtility tool for converting various files to Markdown
fastapiFastAPI framework, high performance, easy to learn, fast to code, ready for production
djangoA high-level Python web framework that encourages rapid development and clean, pragmatic design.
flaskA simple framework for building complex web applications.

More in Frameworks

langchainThe agent engineering platform
deer-flowAn open-source long-horizon SuperAgent harness that researches, codes, and creates. With the help of sandboxes, memories, tools, skill, subagents and message gateway, it handles different levels of ta
tqdmFast, Extensible Progress Meter
simBuild, deploy, and orchestrate AI agents. Sim is the central intelligence layer for your AI workforce.