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

Uploaded Python 3

File details

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

File metadata

  • Download URL: moat_lib_broadcast-0.1.4.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for moat_lib_broadcast-0.1.4.tar.gz
Algorithm Hash digest
SHA256 c05085f003a80765f23689507a4b7d0943793ec584c058e42ef94bc25b8b8320
MD5 35093def2dba9bccb3b7361016c42b50
BLAKE2b-256 9005c0fbd1b1ddbc458c923eb3c54adc8c931188d9bb0b9641e20de4c3456cea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for moat_lib_broadcast-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a054fd3b229b03f13c349232f5c75fd515f16146eeac40a247f76b714de73275
MD5 48c963d698d6e1997ce567d5efb127f0
BLAKE2b-256 2bff08411519d49d9d41fbe71158517abbca79154e25acb9194da9cd0834c921

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