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.5

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.5
File Size Uploaded
moat_lib_broadcast-0.1.5.tar.gz 6.7 kB Details

Built distribution (wheel)

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

Total release size: 12.0 kB

Release files / moat_lib_broadcast-0.1.5.tar.gz

Download URL moat_lib_broadcast-0.1.5.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a12211340b5fe1d95e15be5b0aa7274760eab6e63fb0f4bf998f0960515c11e8
BLAKE2b-256 checksum
How to use checksums
70c667ae1cc45b3126acb0b2bdc94b3dcad025c4545bff768ec8526a30c7cc23
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.5-py3-none-any.whl

Download URL moat_lib_broadcast-0.1.5-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a02aed1fa50b4ca7f5a6d61669cd3aef738f7eb144988268eb9490e2d4a28c0c
BLAKE2b-256 checksum
How to use checksums
ca24426078567da1c0198e3902cf44c028357a41c898801cadac9a9bd32bc225
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

0.1.6

2 release files

This release

0.1.5 This release

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