Skip to main content

Coverage CI

This library enables concurrent iteration over the same stream of values asynchronously. This can be achieved by either creating a Queue that can be iterated simultanously from multiple consumers or wrapping an async generator to make it also iterable simultaously.

Below is an example of MultiQueue use.

import asyncio
from aio_broadcast import MultiQueue


async def print_stream(stream, name, delay):
    async for i in stream:
        await asyncio.sleep(delay)
        print(name, i)


async def main():
    stream = MultiQueue()
    consumers = [asyncio.create_task(print_stream(stream, f"consumer {i}", 1 / (i + 1))) for i in range(5)]
    for i in range(5):
        await asyncio.sleep(0.2)
        stream.put(i)
    stream.close()
    await asyncio.gather(*consumers)


asyncio.run(main())

An async generator can be iterated through simultanously as follows.

import asyncio
from aio_broadcast import broadcast
import random

random.seed(0)


async def consume_stream(stream, name):
    async for value in stream:
        await asyncio.sleep(random.uniform(0, 0.1))
        print(name, value)


async def stream(values):
    for value in values:
        await asyncio.sleep(random.uniform(0, 0.5))
        yield value


async def main():
    values = list(range(5))
    source_stream = broadcast(stream(values))
    await asyncio.gather(
        *[consume_stream(source_stream) for _ in range(3)],
    )


asyncio.run(main())

Metadata

Release files for aio-broadcast 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aio-broadcast 1.0.3
File Size Uploaded Provenance
aio_broadcast-1.0.3.tar.gz 31.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aio-broadcast 1.0.3
File Interpreter ABI Platform
aio_broadcast-1.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 59.7 kB

Release files / aio_broadcast-1.0.3.tar.gz

Download URL aio_broadcast-1.0.3.tar.gz
Size 31.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ce61b913f23f8a788678ef23570b565973899300fadb3c4585719b9a84bd9f3b
BLAKE2b-256 checksum
How to use checksums
2cc0ca89a231ccbe3189d742b2827a29be7bf8260e79367fbab5da2f3a30fe66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 13, 2025.

Transparency log

Release files / aio_broadcast-1.0.3-py3-none-any.whl

Download URL aio_broadcast-1.0.3-py3-none-any.whl
Size 27.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3286d4ea944202cb7a23f8319c5e22820c8581315c5e1b767f884354e00e2974
BLAKE2b-256 checksum
How to use checksums
7561ed5286564d5ab3790b216ae57027c4c7bd87d3c7db0c24aa27514fb2aa9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 13, 2025.

Transparency log

Security for aio-broadcast 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aio_broadcast-1.0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 13, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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