pywebtransport


Namepywebtransport JSON
Version 0.1.2 PyPI version JSON
download
home_pageNone
SummaryA high-performance, async-native WebTransport implementation for Python.
upload_time2025-07-29 19:23:51
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords async http3 networking quic webtransport
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # PyWebTransport

[![PyPI version](https://badge.fury.io/py/pywebtransport.svg)](https://badge.fury.io/py/pywebtransport)
[![Python](https://img.shields.io/pypi/pyversions/pywebtransport.svg)](https://pypi.org/project/pywebtransport/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Build Status](https://github.com/lemonsterfy/pywebtransport/workflows/CI/badge.svg)](https://github.com/lemonsterfy/pywebtransport/actions)
[![Coverage](https://codecov.io/gh/lemonsterfy/pywebtransport/branch/main/graph/badge.svg)](https://codecov.io/gh/lemonsterfy/pywebtransport)

A high-performance, async-native WebTransport implementation for Python.

## Features

- Full WebTransport protocol implementation (bidirectional streams, unidirectional streams, datagrams)
- High-performance async client and server implementations
- Production-ready connection pooling and load balancing
- Comprehensive monitoring and debugging capabilities
- Type-safe API with complete type annotations
- Extensive test coverage (unit, integration, end-to-end)

## Installation

```bash
pip install pywebtransport
```

For development installation:

```bash
git clone https://github.com/lemonsterfy/pywebtransport.git
cd pywebtransport
pip install -e ".[dev]"
```

## Quick Start

### Server

```python
# server.py
import asyncio

from pywebtransport import ServerApp, ServerConfig, WebTransportSession, WebTransportStream
from pywebtransport.exceptions import ConnectionError, SessionError
from pywebtransport.utils import generate_self_signed_cert

generate_self_signed_cert("localhost")

app = ServerApp(
    config=ServerConfig.create(
        certfile="localhost.crt",
        keyfile="localhost.key",
    )
)


async def handle_datagrams(session: WebTransportSession) -> None:
    try:
        while True:
            data = await session.datagrams.receive()
            await session.datagrams.send(b"ECHO: " + data)
    except (ConnectionError, SessionError, asyncio.CancelledError):
        pass


async def handle_streams(session: WebTransportSession) -> None:
    try:
        async for stream in session.incoming_streams():
            if isinstance(stream, WebTransportStream):
                data = await stream.read_all()
                await stream.write_all(b"ECHO: " + data)
    except (ConnectionError, SessionError, asyncio.CancelledError):
        pass


@app.route("/")
async def echo_handler(session: WebTransportSession) -> None:
    datagram_task = asyncio.create_task(handle_datagrams(session))
    stream_task = asyncio.create_task(handle_streams(session))
    try:
        await session.wait_closed()
    finally:
        datagram_task.cancel()
        stream_task.cancel()


if __name__ == "__main__":
    app.run(host="127.0.0.1", port=4433)

```

### Client

```python
# client.py
import asyncio
import ssl

from pywebtransport import ClientConfig, WebTransportClient


async def main() -> None:
    config = ClientConfig.create(verify_mode=ssl.CERT_NONE)

    async with WebTransportClient.create(config=config) as client:
        async with await client.connect("https://127.0.0.1:4433/") as session:
            print("Connection established. Testing datagrams...")
            await session.datagrams.send(b"Hello, Datagram!")
            response = await session.datagrams.receive()
            print(f"Datagram echo: {response!r}\n")

            print("Testing streams...")
            stream = await session.create_bidirectional_stream()
            await stream.write_all(b"Hello, Stream!")
            response = await stream.read_all()
            print(f"Stream echo: {response!r}")


if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        pass

```

## Documentation

- **[Installation Guide](docs/installation.md)** - Setup and installation
- **[Quick Start](docs/quickstart.md)** - 5-minute tutorial
- **[Client Guide](docs/user-guide/client.md)** - Client development patterns
- **[Server Guide](docs/user-guide/server.md)** - Server development patterns
- **[API Reference](docs/api-reference/)** - Complete API documentation

## Requirements

- Python 3.8+
- asyncio support
- TLS 1.3

**Dependencies:**

- aioquic >= 1.2.0
- cryptography >= 45.0.4
- typing-extensions >= 4.14.0 (Python < 3.10)

## Contributing

Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.

**Development Setup:**

```bash
git clone https://github.com/lemonsterfy/pywebtransport.git
cd pywebtransport
pip install -e ".[dev]"
pre-commit install
pytest
```

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- [aioquic](https://github.com/aiortc/aioquic) for QUIC protocol implementation
- [WebTransport Working Group](https://datatracker.ietf.org/wg/webtrans/) for protocol standardization

## Support

- **Issues**: [GitHub Issues](https://github.com/lemonsterfy/pywebtransport/issues)
- **Discussions**: [GitHub Discussions](https://github.com/lemonsterfy/pywebtransport/discussions)
- **Email**: lemonsterfy@gmail.com

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pywebtransport",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "async, http3, networking, quic, webtransport",
    "author": null,
    "author_email": "lemonsterfy <lemonsterfy@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/04/cd/c50dee619cb2eb7198c2ecd273e23196fce5732340d66152372cba4788b2/pywebtransport-0.1.2.tar.gz",
    "platform": null,
    "description": "# PyWebTransport\n\n[![PyPI version](https://badge.fury.io/py/pywebtransport.svg)](https://badge.fury.io/py/pywebtransport)\n[![Python](https://img.shields.io/pypi/pyversions/pywebtransport.svg)](https://pypi.org/project/pywebtransport/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Build Status](https://github.com/lemonsterfy/pywebtransport/workflows/CI/badge.svg)](https://github.com/lemonsterfy/pywebtransport/actions)\n[![Coverage](https://codecov.io/gh/lemonsterfy/pywebtransport/branch/main/graph/badge.svg)](https://codecov.io/gh/lemonsterfy/pywebtransport)\n\nA high-performance, async-native WebTransport implementation for Python.\n\n## Features\n\n- Full WebTransport protocol implementation (bidirectional streams, unidirectional streams, datagrams)\n- High-performance async client and server implementations\n- Production-ready connection pooling and load balancing\n- Comprehensive monitoring and debugging capabilities\n- Type-safe API with complete type annotations\n- Extensive test coverage (unit, integration, end-to-end)\n\n## Installation\n\n```bash\npip install pywebtransport\n```\n\nFor development installation:\n\n```bash\ngit clone https://github.com/lemonsterfy/pywebtransport.git\ncd pywebtransport\npip install -e \".[dev]\"\n```\n\n## Quick Start\n\n### Server\n\n```python\n# server.py\nimport asyncio\n\nfrom pywebtransport import ServerApp, ServerConfig, WebTransportSession, WebTransportStream\nfrom pywebtransport.exceptions import ConnectionError, SessionError\nfrom pywebtransport.utils import generate_self_signed_cert\n\ngenerate_self_signed_cert(\"localhost\")\n\napp = ServerApp(\n    config=ServerConfig.create(\n        certfile=\"localhost.crt\",\n        keyfile=\"localhost.key\",\n    )\n)\n\n\nasync def handle_datagrams(session: WebTransportSession) -> None:\n    try:\n        while True:\n            data = await session.datagrams.receive()\n            await session.datagrams.send(b\"ECHO: \" + data)\n    except (ConnectionError, SessionError, asyncio.CancelledError):\n        pass\n\n\nasync def handle_streams(session: WebTransportSession) -> None:\n    try:\n        async for stream in session.incoming_streams():\n            if isinstance(stream, WebTransportStream):\n                data = await stream.read_all()\n                await stream.write_all(b\"ECHO: \" + data)\n    except (ConnectionError, SessionError, asyncio.CancelledError):\n        pass\n\n\n@app.route(\"/\")\nasync def echo_handler(session: WebTransportSession) -> None:\n    datagram_task = asyncio.create_task(handle_datagrams(session))\n    stream_task = asyncio.create_task(handle_streams(session))\n    try:\n        await session.wait_closed()\n    finally:\n        datagram_task.cancel()\n        stream_task.cancel()\n\n\nif __name__ == \"__main__\":\n    app.run(host=\"127.0.0.1\", port=4433)\n\n```\n\n### Client\n\n```python\n# client.py\nimport asyncio\nimport ssl\n\nfrom pywebtransport import ClientConfig, WebTransportClient\n\n\nasync def main() -> None:\n    config = ClientConfig.create(verify_mode=ssl.CERT_NONE)\n\n    async with WebTransportClient.create(config=config) as client:\n        async with await client.connect(\"https://127.0.0.1:4433/\") as session:\n            print(\"Connection established. Testing datagrams...\")\n            await session.datagrams.send(b\"Hello, Datagram!\")\n            response = await session.datagrams.receive()\n            print(f\"Datagram echo: {response!r}\\n\")\n\n            print(\"Testing streams...\")\n            stream = await session.create_bidirectional_stream()\n            await stream.write_all(b\"Hello, Stream!\")\n            response = await stream.read_all()\n            print(f\"Stream echo: {response!r}\")\n\n\nif __name__ == \"__main__\":\n    try:\n        asyncio.run(main())\n    except KeyboardInterrupt:\n        pass\n\n```\n\n## Documentation\n\n- **[Installation Guide](docs/installation.md)** - Setup and installation\n- **[Quick Start](docs/quickstart.md)** - 5-minute tutorial\n- **[Client Guide](docs/user-guide/client.md)** - Client development patterns\n- **[Server Guide](docs/user-guide/server.md)** - Server development patterns\n- **[API Reference](docs/api-reference/)** - Complete API documentation\n\n## Requirements\n\n- Python 3.8+\n- asyncio support\n- TLS 1.3\n\n**Dependencies:**\n\n- aioquic >= 1.2.0\n- cryptography >= 45.0.4\n- typing-extensions >= 4.14.0 (Python < 3.10)\n\n## Contributing\n\nContributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details.\n\n**Development Setup:**\n\n```bash\ngit clone https://github.com/lemonsterfy/pywebtransport.git\ncd pywebtransport\npip install -e \".[dev]\"\npre-commit install\npytest\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\n- [aioquic](https://github.com/aiortc/aioquic) for QUIC protocol implementation\n- [WebTransport Working Group](https://datatracker.ietf.org/wg/webtrans/) for protocol standardization\n\n## Support\n\n- **Issues**: [GitHub Issues](https://github.com/lemonsterfy/pywebtransport/issues)\n- **Discussions**: [GitHub Discussions](https://github.com/lemonsterfy/pywebtransport/discussions)\n- **Email**: lemonsterfy@gmail.com\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A high-performance, async-native WebTransport implementation for Python.",
    "version": "0.1.2",
    "project_urls": {
        "Changelog": "https://github.com/lemonsterfy/pywebtransport/blob/main/CHANGELOG.md",
        "Documentation": "https://pywebtransport.readthedocs.io",
        "Homepage": "https://github.com/lemonsterfy/pywebtransport",
        "Issues": "https://github.com/lemonsterfy/pywebtransport/issues",
        "Repository": "https://github.com/lemonsterfy/pywebtransport.git"
    },
    "split_keywords": [
        "async",
        " http3",
        " networking",
        " quic",
        " webtransport"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2ffa07c4b6e2ddc5db35a5c32dfd7d3a81caf3213bb1eda094aee856878aff16",
                "md5": "d08ad211efe9c9ed1e8bd015beca3b8f",
                "sha256": "8ba443c289e758d4450b9915696874fada389e8f362f60a1b9c0b9793694ab67"
            },
            "downloads": -1,
            "filename": "pywebtransport-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d08ad211efe9c9ed1e8bd015beca3b8f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 118009,
            "upload_time": "2025-07-29T19:23:53",
            "upload_time_iso_8601": "2025-07-29T19:23:53.575624Z",
            "url": "https://files.pythonhosted.org/packages/2f/fa/07c4b6e2ddc5db35a5c32dfd7d3a81caf3213bb1eda094aee856878aff16/pywebtransport-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "04cdc50dee619cb2eb7198c2ecd273e23196fce5732340d66152372cba4788b2",
                "md5": "ed405556c75a29aed102f5c32fff08fe",
                "sha256": "477b98c154c5cb218423c7d47d879ab00f74a8908ec4e400cf8ec6214ce51d12"
            },
            "downloads": -1,
            "filename": "pywebtransport-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ed405556c75a29aed102f5c32fff08fe",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 89869,
            "upload_time": "2025-07-29T19:23:51",
            "upload_time_iso_8601": "2025-07-29T19:23:51.821711Z",
            "url": "https://files.pythonhosted.org/packages/04/cd/c50dee619cb2eb7198c2ecd273e23196fce5732340d66152372cba4788b2/pywebtransport-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-29 19:23:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lemonsterfy",
    "github_project": "pywebtransport",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pywebtransport"
}
        
Elapsed time: 1.17030s