Multi consumers asyncio compatible queue
Project description
A simple multi-consumer asyncio-compatible queue, useful for duplicating a stream of events, as demonstrated below.
import asyncio
from aio_broadcast import Broadcast
async def print_stream(stream, name, delay):
async for i in stream:
await asyncio.sleep(delay)
print(name, i)
async def feed_stream(nb_values, live_stream: Broadcast[int]):
for i in range(nb_values):
await asyncio.sleep(0.2)
live_stream.put(i)
live_stream.close()
async def main():
source_stream = Broadcast()
await asyncio.gather(
feed_stream(5, source_stream),
print_stream(source_stream, "fast", 0.5),
print_stream(source_stream, "slow", 1),
)
asyncio.run(main())
fast 0
slow 0
fast 1
slow 1
fast 2
fast 3
slow 2
fast 4
slow 3
slow 4
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aio_broadcast-1.0.2.tar.gz.
File metadata
- Download URL: aio_broadcast-1.0.2.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1d7c7a3771a0e1d29dbc482c3d850bc3f49a3bc5ead1c78049be1c8d8ca264c
|
|
| MD5 |
1b890ec8ccf7bcdef0a61ef099a07532
|
|
| BLAKE2b-256 |
5750c26e419e65b9bd9ec609fb66b83fcd6ab5b16b4f6f21df8ec55a543fc921
|
Provenance
The following attestation bundles were made for aio_broadcast-1.0.2.tar.gz:
Publisher:
ci.yml on pytek-io/aio-broadcast
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aio_broadcast-1.0.2.tar.gz -
Subject digest:
e1d7c7a3771a0e1d29dbc482c3d850bc3f49a3bc5ead1c78049be1c8d8ca264c - Sigstore transparency entry: 180397533
- Sigstore integration time:
-
Permalink:
pytek-io/aio-broadcast@3780d2e2a6ae59e8f562a375d25e6fbf7ee0f02f -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/pytek-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@3780d2e2a6ae59e8f562a375d25e6fbf7ee0f02f -
Trigger Event:
push
-
Statement type:
File details
Details for the file aio_broadcast-1.0.2-py3-none-any.whl.
File metadata
- Download URL: aio_broadcast-1.0.2-py3-none-any.whl
- Upload date:
- Size: 27.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10fc401ed81255585bc15890e8b24d96594ba6948d4138091999b14afaedc0ef
|
|
| MD5 |
3374a53860651dbaaa13cb37178fb8b1
|
|
| BLAKE2b-256 |
10e09ffadd68af96c6a775e837d9924097a3b3b72f3b02637204ae4efeb733c2
|
Provenance
The following attestation bundles were made for aio_broadcast-1.0.2-py3-none-any.whl:
Publisher:
ci.yml on pytek-io/aio-broadcast
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aio_broadcast-1.0.2-py3-none-any.whl -
Subject digest:
10fc401ed81255585bc15890e8b24d96594ba6948d4138091999b14afaedc0ef - Sigstore transparency entry: 180397534
- Sigstore integration time:
-
Permalink:
pytek-io/aio-broadcast@3780d2e2a6ae59e8f562a375d25e6fbf7ee0f02f -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/pytek-io
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@3780d2e2a6ae59e8f562a375d25e6fbf7ee0f02f -
Trigger Event:
push
-
Statement type: