Skip to main content

Broadcasting

% start synopsis % start main

This module provides async broadcasting, with a finite message queue.

The writer does not block; the reader supports data loss detection.

% end synopsis % end main

Usage

from moat.lib.broadcast import Broadcaster
import anyio
from contextlib import aclosing

async def reader(bc):
    async with aclosing(bc) as mq:
        async for msg in mq:
            print(f"Received: {msg}")

async with anyio.create_task_group() as tg, Broadcaster() as bc:
    # Start readers
    tg.start_soon(reader, aiter(bc))
    tg.start_soon(reader, bc.reader(10))  # explicit queue length

    # Send messages
    bc("Hello")
    await anyio.sleep(0.01)
    bc("World")

License

This project is part of the MoaT ecosystem and is licensed under the same terms.

Metadata

Release files for moat-lib-broadcast 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moat-lib-broadcast 0.1.6
File Size Uploaded
moat_lib_broadcast-0.1.6.tar.gz 6.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moat-lib-broadcast 0.1.6
File Interpreter ABI Platform
moat_lib_broadcast-0.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / moat_lib_broadcast-0.1.6.tar.gz

Download URL moat_lib_broadcast-0.1.6.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
3e7b8b81b46b34c036f6be2fbcee2de639c7fc38685258f0f443b493d55bf0f0
BLAKE2b-256 checksum
How to use checksums
0b4e52078d81c784213c82385289f01cde02f76af892d87aef4d679f05b19553
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / moat_lib_broadcast-0.1.6-py3-none-any.whl

Download URL moat_lib_broadcast-0.1.6-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cd63fc72a3e6949cd8625157bb9dc3bc0d04526b2a76c05e8427a13be509649c
BLAKE2b-256 checksum
How to use checksums
30f72cf6bf86df71a63e3b4645fca607fad78ed8813a8ad5787d92624d18808f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page