Skip to main content

Broadcasting support for MoaT applications

Project description

Broadcasting

% start synopsis

This module provides async broadcasting, with a finite, non-blocking message queue and data loss detection.

% end synopsis

Installation

pip install moat-lib-broadcast

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.2.tar.gz (6.0 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.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: moat_lib_broadcast-0.1.2.tar.gz
  • Upload date:
  • Size: 6.0 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.2.tar.gz
Algorithm Hash digest
SHA256 ddbe478cc1d2896890e7b6795fabc1146168a206d3b565bc437cbb2b94d33416
MD5 2cbd11457b866cea07efd85983de8e2f
BLAKE2b-256 f09eb471ac5c7af9d93d3dfb3885cc181648d2b487d5ec8dc47b272fa5f7fe26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for moat_lib_broadcast-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b7278f821587c7912657366109c52c87dc2786d2e678465e01a9a55ea5f26eb6
MD5 21649954370d89b5c9533694f6b56e79
BLAKE2b-256 d2e901175bc32e0f46969e0dc3d046e19c8404caeb34c7c284e669bb7488e7e0

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