Registry / data / faust-streaming

faust-streaming

JSON →
library0.11.3pypypi✓ verified 86d ago

Faust-streaming is a Python stream processing library that ports concepts from Kafka Streams to Python. It enables building high-performance distributed systems and real-time data pipelines. This project is an actively maintained fork of the original Faust library, aiming for continuous releases, improved code quality, and support for the latest Kafka drivers. The current version is 0.11.3, with releases happening periodically based on community contributions and dependency updates.

pip install faust-streaming
INSTALL
IMPORT
SIG · FAUST-STREAMING
F
faust-streaming
datapythonv0.11.3
Install
8.4s avg
Import
1048ms
Disk
47MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.11.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
build_error
glibc
py 3.103.920 runs
installs and imports cleanly · install 8.4s · import 1.048s · 49MB
47MB installed
● package 47MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

App
from faust import App
Record
from faust import Record

This quickstart demonstrates a basic Faust streaming application. It initializes a Faust application, defines a `Record` model for incoming data, sets up a Kafka topic, and creates an `@app.agent` to consume and process messages from that topic. The Kafka broker address is configurable via an environment variable.

import faust import os # Configure Kafka broker from environment variable or default to localhost KAFKA_BROKER = os.environ.get('FAUST_BROKER', 'kafka://localhost:9092') app = faust.App( 'my-streaming-app', broker=KAFKA_BROKER, value_serializer='json', ) # Define a data model for messages class Order(faust.Record): account_id: str amount: float item_id: str # Define an input topic using the Order model orders_topic = app.topic('orders', value_type=Order) # Define an agent to process messages from the 'orders' topic @app.agent(orders_topic) async def process_orders(orders): async for order in orders: print(f"Processing order {order.item_id} for account {order.account_id}: ${order.amount}") # Example: Perform some asynchronous operation or send to another topic # await another_topic.send(value={'processed': True, 'order_id': order.item_id}) # To run this worker: save as app.py, then execute 'faust -A app worker -l info'
faust --version
Debug
Known issues
breakingUpgrading to v0.11.2 changed the internal `aiokafka` topic error handling (`topic_errors` was renamed) and bumped the minimum `aiokafka` version to `0.10.0`. Older `aiokafka` versions may cause compatibility issues.
fix
Ensure `aiokafka` is updated to a compatible version (>=0.10.0, preferably latest stable) when upgrading `faust-streaming`. Review any custom code interacting directly with `aiokafka` internals.
affects: >=0.11.2
gotchaUsers reported that consumers could 'slowly die over time' or stop receiving messages after upgrading to `v0.11.2` from `v0.11.1`. This might be related to stream processing timeouts or agent hanging.
fix
Monitor `stream_processing_timeout` and agent logs for errors. Consider increasing `stream_processing_timeout` if processing individual events takes longer than the default. Review agent logic for potential deadlocks or long-running synchronous operations.
affects: 0.11.2
breakingVersion `0.11.0` included fixes for imports from `mode-streaming~=0.4.0`. This indicates a strong compatibility requirement with `mode-streaming` version `0.4.0` or newer.
fix
Ensure `mode-streaming` is installed at version `0.4.0` or higher to avoid import errors and ensure correct functionality when using `faust-streaming >=0.11.0`.
affects: >=0.11.0
breakingChanging the `key_type` or `value_type` of an existing topic is a backward-incompatible change. All Faust instances using the old types must be restarted. Renaming model classes can also cause deserialization errors if not handled with an upgrade strategy.
fix
Plan for schema evolution. For topic type changes, implement an upgrade path (e.g., new topic for new schema) and ensure all consumers/producers are updated. For model renames, ensure old model names are still resolvable or provide a migration.
affects: all
gotchaConcurrent agents are explicitly not allowed to modify tables. Attempting to do so will raise an exception.
fix
Design agents that modify tables to run with a concurrency of 1, or ensure that only non-concurrent agents perform table modifications. Concurrent agents should only read from tables.
affects: all
Errors
Common errors & fixes
AttributeError: 'CreateTopicsRequest_v1' object has no attribute 'build_request_header'
This error occurs due to an incompatibility between your faust-streaming version and the installed aiokafka library version, often because newer aiokafka versions have removed the `build_request_header` attribute.
fix
Pin your aiokafka dependency to a compatible older version (e.g., `pip install "aiokafka<0.11.0"`) or upgrade faust-streaming to its latest version which might have updated aiokafka compatibility.
ModuleNotFoundError: No module named 'your_app_module'
The faust command-line interface cannot locate the Python module that contains your faust.App instance. This usually happens if the module is not in the Python path or the -A argument specifies an incorrect path.
fix
Ensure the `faust -A your_app_module worker` command is executed from a directory where `your_app_module.py` (or the package containing it) is importable. For example, if your app is in `myproject/app.py`, run `faust -A myproject.app worker` from the directory containing `myproject`.
[ERROR] Unable connect to "broker_address:port": [Errno 113] Connect call failed
The Faust worker is unable to establish a connection to the configured Kafka broker. This can be due to an incorrect broker address or port, the Kafka broker not running, network connectivity issues, or firewall restrictions.
fix
Verify that the Kafka broker address and port specified in `faust.App(..., broker='kafka://...')` are correct. Ensure the Kafka broker is running and is reachable from the machine where the Faust worker is being started. Check network configurations and firewall settings.
TypeError: Stream has no current event
This error typically occurs within a Faust agent when `stream.current_event` is accessed, but the stream has no current event being processed, often because the topic is empty or the stream iteration has concluded prematurely.
fix
Implement error handling around `stream.current_event` access, or ensure that you are only accessing `current_event` inside the `async for` loop where an event is guaranteed to be present. Consider the `stream_wait_empty` setting in your `faust.App` configuration.
fastavro._schema_common.SchemaParseException: redefined named type: foo
This error occurs during Avro serialization when defining Faust models (faust.Record) that involve union types or enums, and there are duplicate named types (e.g., enums or record fields) across the union members or within enums without proper namespacing.
fix
Ensure that when using Avro models, all named types (including enums and nested records within unions) have unique names or are properly namespaced. For `faust.Record` classes, you may need to define a `Meta` class with a `namespace` attribute.
Upgrade
Version history
0.11.3latest on PyPI · released Aug 23, 2024
Audit
Dependencies
aiokafkarequiredUnderlying asynchronous Kafka client used for consuming and producing messages.
mode-streamingrequiredCore dependency for async primitives and service management.
RocksDBoptionalUsed for local state storage in tables (C++ embedded database). Not a direct Python installable, but an underlying component.
Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
1
Resources
faust-streaming — pip install faust-streaming · libregistry