An async stream processing microframework
Project description
An async stream processing microframework for Python
Introduction
Slurry builds on the concepts of structured concurrency and memory channels, originating in Trio, and uses them to create a microframework for processing streaming data.
The basic building blocks of Slurry includes:
Pipelines - An asynchronous context manager which encapsulates a stream process.
Sections - The individual processing steps.
Taps - Output channels for the processed stream.
Extensions - A way to add more processing steps to an existing pipeline.
Slurry avoids using asynchronous generator functions, in favor of the pull-push programming style of memory channels. It can be thought of as an asynchronous version of itertools - on steroids!
Included in the basic library are a number of basic stream processing building blocks, like Map, Chain, Merge and Zip, and it is easy to build your own!
Demonstration
Enough talk! Time to see what’s up!
async with Pipeline.create(
Zip(produce_increasing_integers(1, max=3), produce_alphabet(0.9, max=3))
) as pipeline, pipeline.tap() as aiter:
results = [item async for item in aiter]
assert results == [(0,'a'), (1, 'b'), (2, 'c')]
The example producers (which are not part of the framework) could look like this:
async def produce_increasing_integers(interval, *, max=3):
for i in range(max):
yield i
if i == max-1:
break
await trio.sleep(interval)
async def produce_alphabet(interval, *, max=3):
for i, c in enumerate(string.ascii_lowercase):
yield c
if i == max - 1:
break
await trio.sleep(interval)
Further documentation is available on readthedocs. Check out the source code on github.
Installation
Still here? Wanna try it out yourself? Install from PyPI:
pip install slurry
Slurry is tested on Python 3.8 or greater and requires the Trio concurrency and IO library.
License
Slurry is licensed under the MIT license.
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
File details
Details for the file Slurry-1.3.1.tar.gz
.
File metadata
- Download URL: Slurry-1.3.1.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.10.6 Linux/5.15.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38abbdbe8abc79204014ad2e81c0fee54c060f41af7bb3206d7862ef3cb2c47e |
|
MD5 | 1fd28e2c8340f3331acc039bcf45fe3d |
|
BLAKE2b-256 | 65e4a5b710f331b02ddf07cf4e529d07c54f4e4817753349ad15cc3fd1f4b6ea |
File details
Details for the file Slurry-1.3.1-py3-none-any.whl
.
File metadata
- Download URL: Slurry-1.3.1-py3-none-any.whl
- Upload date:
- Size: 19.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.8 CPython/3.10.6 Linux/5.15.0-1017-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7cab793a35c38dc3504399a2754e4fb8125877474c2ab96d0015be68ac6fae0 |
|
MD5 | 787442a02d95956c6e59db9da0048ddf |
|
BLAKE2b-256 | baca6f197656ab63980f7ca1819bbd633a2c9c5e6c48dd8d681fdc255a1243f4 |