AioUDP
A better API for asynchronous UDP
A websockets-like API for UDP
Here's an example echo server:
import asyncio
import signal
import aioudp
async def main():
async def handler(connection):
async for message in connection:
await connection.send(message)
loop = asyncio.get_running_loop()
stop = loop.create_future()
# Optional. This is for properly exiting the server when Ctrl-C is pressed
# or when the process is killed/terminated
loop.add_signal_handler(signal.SIGTERM, stop.set_result, None)
loop.add_signal_handler(signal.SIGINT, stop.set_result, None)
# Serve the server
async with aioudp.serve("localhost", 9999, handler):
await stop # Serve forever
if __name__ == '__main__':
asyncio.run(main())
And a client to connect to the server:
import asyncio
import aioudp
async def main():
async with aioudp.connect("localhost", 9999) as connection:
await connection.send(b"Hello world!")
assert await connection.recv() == b"Hello world!"
if __name__ == '__main__':
asyncio.run(main())
Installation
You can get this project via pip
$ pip install aioudp
Or, if you're using Poetry
$ poetry add aioudp
[!NOTE] This library provides no other abstractions over the existing UDP interface in
asyncioother than theasync/await-based API. This means there is no implicit protocol handled in this library such as QUIC. You must write your own, or find another library.
See also
- AnyIO, a broader asynchronous networking and concurrency library for abstracting over any
asyncIO implementation. It has a similar API (which I didn't know about before I wrote this library) - WebSockets, a library for Python to interact with WebSockets. Its API heavily inspired the design of AioUDP.
- QUIC, a faster protocol similar to TCP, built on UDP.
- AioQUIC, a Python implementation of QUIC.
License
Copyright © 2021, Bryan Hu
This project is licensed under the GNU GPL v3+.
In short, this means you can do anything with it (distribute, modify, sell) but if you were to publish your changes, you must make the source code and build instructions readily available.
If you are a company using this project and want an exception, email me at thatxliner@gmail.com and we can discuss.
Metadata
Release files for aioudp 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aioudp-2.0.0.tar.gz | 20.2 kB | With provenance | Details for aioudp-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aioudp-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for aioudp-2.0.0-py3-none-any.whl |
Total release size: 40.3 kB
Release files / aioudp-2.0.0.tar.gz
| Download URL | aioudp-2.0.0.tar.gz |
|---|---|
| Size | 20.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b38ddb1fac433ec8fa209e1aa2c83907c9d805af08d8a1b5a8e7983df94137c8
|
|
BLAKE2b-256 checksum How to use checksums |
ec4f0e9b87b80d801d06d3c4ad8fbd3cf46bb79162d7e842986ee4fc1f206d63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 1, 2025.
Transparency logRelease files / aioudp-2.0.0-py3-none-any.whl
| Download URL | aioudp-2.0.0-py3-none-any.whl |
|---|---|
| Size | 20.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78c4f8ca0d9617f2138514d4cc316caad3d19f2799bf6e3a60acce848d07c5b4
|
|
BLAKE2b-256 checksum How to use checksums |
2719e256c486757b66af54fb2c600bfab2679d14768061bb34bfdea60719dc6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 1, 2025.
Transparency logSecurity for aioudp 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for aioudp-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 1, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.