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.

Release files for moat-lib-broadcast 0.1.4

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.4
File Size Uploaded
moat_lib_broadcast-0.1.4.tar.gz 6.4 kB Details

Built distribution (wheel)

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

Total release size: 11.5 kB

Release files / moat_lib_broadcast-0.1.4.tar.gz

Download URL moat_lib_broadcast-0.1.4.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c05085f003a80765f23689507a4b7d0943793ec584c058e42ef94bc25b8b8320
BLAKE2b-256 checksum
How to use checksums
9005c0fbd1b1ddbc458c923eb3c54adc8c931188d9bb0b9641e20de4c3456cea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

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

Download URL moat_lib_broadcast-0.1.4-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a054fd3b229b03f13c349232f5c75fd515f16146eeac40a247f76b714de73275
BLAKE2b-256 checksum
How to use checksums
2bff08411519d49d9d41fbe71158517abbca79154e25acb9194da9cd0834c921
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release history Release notifications | RSS feed

This release

0.1.4 This release

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