aioudp


Nameaioudp JSON
Version 1.0.1 PyPI version JSON
download
home_pagehttps://github.com/ThatXliner/aioudp
SummaryA better API for asynchronous UDP
upload_time2024-01-04 21:06:47
maintainer
docs_urlNone
authorBryan Hu
requires_python>=3.8,<4.0
licenseGPL-3.0-or-later
keywords udp asyncio
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AioUDP

[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![codecov](https://codecov.io/gh/ThatXliner/aioudp/branch/main/graph/badge.svg)](https://codecov.io/gh/ThatXliner/aioudp)

[![Documentation Status](https://readthedocs.org/projects/aioudp/badge/?version=latest)](https://aioudp.readthedocs.io/en/latest/?badge=latest)
[![CI](https://github.com/ThatXliner/aioudp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ThatXliner/aioudp/actions/workflows/ci.yml)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aioudp)](https://pypi.org/project/aioudp)
[![PyPI](https://img.shields.io/pypi/v/aioudp)](https://pypi.org/project/aioudp)
[![PyPI - License](https://img.shields.io/pypi/l/aioudp)](#license)

> A better API for asynchronous UDP

A [websockets](https://websockets.readthedocs.io/en/stable/index.html)-like API for [UDP](https://en.wikipedia.org/wiki/User_Datagram_Protocol)

Here's an example echo server:

```py
import asyncio
import signal

import aioudp


async def main():
    async def handler(connection):
        async for message in connection:
            await connection.send(message)

    # Optional. This is for properly exiting the server when Ctrl-C is pressed
    # or when the process is killed/terminated
    loop = asyncio.get_running_loop()
    stop = loop.create_future()
    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:

```py
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`

```bash
$ pip install aioudp
```


Or, if you're using [Poetry](https://python-poetry.org)

```bash
$ poetry add aioudp
```

> [!NOTE]
> This library provides no other abstractions over the existing UDP interface in `asyncio` other than the `async`/`await`-based API. This means there is no implicit protocol handled in this library such as [QUIC](https://en.wikipedia.org/wiki/QUIC). You must write your own, or find another library.

## See also

- [AnyIO](https://anyio.readthedocs.io/en/stable/index.html), a broader asynchronous networking and concurrency library for abstracting over any `async` IO implementation. It has a [similar API](https://anyio.readthedocs.io/en/stable/networking.html#working-with-udp-sockets) (which I didn't know about before I wrote this library)
- [WebSockets](https://websockets.readthedocs.io/en/stable/), a library for Python to interact with WebSockets. Its API heavily inspired the design of AioUDP.
- [QUIC](https://en.wikipedia.org/wiki/QUIC), a faster protocol similar to TCP, built on UDP.
- [AioQUIC](https://github.com/aiortc/aioquic), a Python implementation of QUIC.

## License

Copyright © 2021, Bryan Hu

This project is licensed under the [GNU GPL v3+](https://github.com/ThatXliner/aioudp/blob/main/LICENSE.txt).

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](mailto:thatxliner@gmail.com) and we can discuss.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ThatXliner/aioudp",
    "name": "aioudp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "udp,asyncio",
    "author": "Bryan Hu",
    "author_email": "thatxliner@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/9e/63/adeecd6c8625de15c20aec266af29ed0dd612700aae26d67e1aa044f2618/aioudp-1.0.1.tar.gz",
    "platform": null,
    "description": "# AioUDP\n\n[![Poetry](https://img.shields.io/endpoint?url=https://python-poetry.org/badge/v0.json)](https://python-poetry.org/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336)](https://pycqa.github.io/isort/)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n[![codecov](https://codecov.io/gh/ThatXliner/aioudp/branch/main/graph/badge.svg)](https://codecov.io/gh/ThatXliner/aioudp)\n\n[![Documentation Status](https://readthedocs.org/projects/aioudp/badge/?version=latest)](https://aioudp.readthedocs.io/en/latest/?badge=latest)\n[![CI](https://github.com/ThatXliner/aioudp/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/ThatXliner/aioudp/actions/workflows/ci.yml)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/aioudp)](https://pypi.org/project/aioudp)\n[![PyPI](https://img.shields.io/pypi/v/aioudp)](https://pypi.org/project/aioudp)\n[![PyPI - License](https://img.shields.io/pypi/l/aioudp)](#license)\n\n> A better API for asynchronous UDP\n\nA [websockets](https://websockets.readthedocs.io/en/stable/index.html)-like API for [UDP](https://en.wikipedia.org/wiki/User_Datagram_Protocol)\n\nHere's an example echo server:\n\n```py\nimport asyncio\nimport signal\n\nimport aioudp\n\n\nasync def main():\n    async def handler(connection):\n        async for message in connection:\n            await connection.send(message)\n\n    # Optional. This is for properly exiting the server when Ctrl-C is pressed\n    # or when the process is killed/terminated\n    loop = asyncio.get_running_loop()\n    stop = loop.create_future()\n    loop.add_signal_handler(signal.SIGTERM, stop.set_result, None)\n    loop.add_signal_handler(signal.SIGINT, stop.set_result, None)\n\n    # Serve the server\n    async with aioudp.serve(\"localhost\", 9999, handler):\n        await stop  # Serve forever\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n\nAnd a client to connect to the server:\n\n```py\nimport asyncio\n\nimport aioudp\n\n\nasync def main():\n    async with aioudp.connect(\"localhost\", 9999) as connection:\n        await connection.send(b\"Hello world!\")\n        assert await connection.recv() == b\"Hello world!\"\n\nif __name__ == '__main__':\n    asyncio.run(main())\n```\n\n## Installation\n\nYou can get this project via `pip`\n\n```bash\n$ pip install aioudp\n```\n\n\nOr, if you're using [Poetry](https://python-poetry.org)\n\n```bash\n$ poetry add aioudp\n```\n\n> [!NOTE]\n> This library provides no other abstractions over the existing UDP interface in `asyncio` other than the `async`/`await`-based API. This means there is no implicit protocol handled in this library such as [QUIC](https://en.wikipedia.org/wiki/QUIC). You must write your own, or find another library.\n\n## See also\n\n- [AnyIO](https://anyio.readthedocs.io/en/stable/index.html), a broader asynchronous networking and concurrency library for abstracting over any `async` IO implementation. It has a [similar API](https://anyio.readthedocs.io/en/stable/networking.html#working-with-udp-sockets) (which I didn't know about before I wrote this library)\n- [WebSockets](https://websockets.readthedocs.io/en/stable/), a library for Python to interact with WebSockets. Its API heavily inspired the design of AioUDP.\n- [QUIC](https://en.wikipedia.org/wiki/QUIC), a faster protocol similar to TCP, built on UDP.\n- [AioQUIC](https://github.com/aiortc/aioquic), a Python implementation of QUIC.\n\n## License\n\nCopyright \u00a9 2021, Bryan Hu\n\nThis project is licensed under the [GNU GPL v3+](https://github.com/ThatXliner/aioudp/blob/main/LICENSE.txt).\n\nIn 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.\n\nIf you are a company using this project and want an exception, email me at [thatxliner@gmail.com](mailto:thatxliner@gmail.com) and we can discuss.\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "A better API for asynchronous UDP",
    "version": "1.0.1",
    "project_urls": {
        "Documentation": "https://aioudp.readthedocs.io/en/latest/index.html",
        "Homepage": "https://github.com/ThatXliner/aioudp"
    },
    "split_keywords": [
        "udp",
        "asyncio"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a945dd3dacb9757bc4172c122524b67105214e498703b2fbf66fad5087fa2e2",
                "md5": "b5cabebde972b68f5f3d0d0316ab0d9e",
                "sha256": "40f3a2bc22c7719c44610d42e7b60b445e1118cd0a33daed7ecb91a4c80a0e63"
            },
            "downloads": -1,
            "filename": "aioudp-1.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b5cabebde972b68f5f3d0d0316ab0d9e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 19421,
            "upload_time": "2024-01-04T21:06:45",
            "upload_time_iso_8601": "2024-01-04T21:06:45.394986Z",
            "url": "https://files.pythonhosted.org/packages/9a/94/5dd3dacb9757bc4172c122524b67105214e498703b2fbf66fad5087fa2e2/aioudp-1.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9e63adeecd6c8625de15c20aec266af29ed0dd612700aae26d67e1aa044f2618",
                "md5": "6da30a8b04132207e163227d32cd63ef",
                "sha256": "f1b6e24ff24c08d34165d0e6bce5fca0bce6c042df6e98c47f7c543f4b7b7c57"
            },
            "downloads": -1,
            "filename": "aioudp-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6da30a8b04132207e163227d32cd63ef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 18045,
            "upload_time": "2024-01-04T21:06:47",
            "upload_time_iso_8601": "2024-01-04T21:06:47.108112Z",
            "url": "https://files.pythonhosted.org/packages/9e/63/adeecd6c8625de15c20aec266af29ed0dd612700aae26d67e1aa044f2618/aioudp-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-04 21:06:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ThatXliner",
    "github_project": "aioudp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aioudp"
}
        
Elapsed time: 0.16662s