Skip to main content

Broadcasting support for MoaT applications

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

moat_lib_broadcast-0.1.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

moat_lib_broadcast-0.1.3-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file moat_lib_broadcast-0.1.3.tar.gz.

File metadata

  • Download URL: moat_lib_broadcast-0.1.3.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for moat_lib_broadcast-0.1.3.tar.gz
Algorithm Hash digest
SHA256 908af2e77dc46fec51848b6ee1e24385399cc9b78d5ca6f6ab96e797ce81a49b
MD5 76bb0bda38145d699ca4f7cf341f3390
BLAKE2b-256 59900e597f9fc9ff0c893aed238f5ff930521a34f0c61e65c0551dd1def48c16

See more details on using hashes here.

File details

Details for the file moat_lib_broadcast-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for moat_lib_broadcast-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d109c9bf6fbcfff460de080f3eb84fff62020962130dd50ac3a601d3a09ec889
MD5 e7c31ed32130ad4c94666728694cd21a
BLAKE2b-256 8b7e2cfa72e79ee0633cf62c69570cf2404ed5bea03f54b7313e811c385bce10

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page