Overview

Date: 2026-05-11

Time: 15:16

Overview

FTL2's event streaming system enables real-time progress reporting during module execution. Modules can emit progress, log, and data events that stream to callers, supporting use cases like progress bars for file transfers, live log output, multi-host tracking, and rich terminal UIs. Events work for both local and remote (SSH) execution and are always captured in results even without an explicit callback.

Key Concepts

Commands and Syntax

Running examples:


uv run python example_streaming.py                # local, no setup
docker-compose up -d && uv run python example_remote_streaming.py  # remote via Docker

Emitting events from modules:


from ftl2.events import emit_progress, emit_log, emit_data
emit_progress(percent=50, message="Copying file", current=512000, total=1024000, task_id="copy-1")
emit_log("message", level="info")       # levels: info, warning, error
emit_data("output\n", stream="stdout")

Streaming executor signatures:

Display setup:


# Rich display — use as context manager
display = EventProgressDisplay(console=None, show_log_events=True, show_data_events=False)
with display:
    result = await execute_local_streaming(path, params, event_callback=display.handle_event)

# Simple display — no context manager needed
display = SimpleEventDisplay(output=sys.stderr, show_log_events=True, show_data_events=False)

Relationships

Exam-Relevant Points