Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:1kbgz Tributary Python Asyncio Runtime

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Async
Last Updated 2026-10-14 09:15 GMT

Overview

Python 3.7+ runtime with asyncio event loop support, required by all tributary streaming and lazy graph implementations.

Description

This environment provides the base Python runtime for the tributary dataflow graph library. It requires Python 3.7 or higher (classified for 3.7 through 3.10 in setup.py) with full asyncio support. The streaming graph engine uses `asyncio.gather` for level-by-level parallel node execution, `asyncio.create_task` for coroutine scheduling, and `asyncio.Queue`-like deques for inter-node communication. On Windows, the `ProactorEventLoop` is explicitly selected for compatibility.

Usage

Use this environment for all tributary workflows — both lazy graph evaluation and streaming data pipelines. It is the mandatory prerequisite for every Implementation in the repository, since both the lazy and streaming Node classes depend on the asyncio event loop (streaming) or synchronous call-by-need evaluation (lazy) within the Python runtime.

System Requirements

Category Requirement Notes
OS Linux, macOS, or Windows Windows requires ProactorEventLoop
Hardware Any CPU No GPU required
Disk 100MB For Python packages and graphviz system library

Dependencies

System Packages

  • `python` >= 3.7
  • `graphviz-dev` (optional, for visualization)

Python Packages

  • `aioconsole` >= 0.2.1
  • `aiofiles` >= 0.4.0
  • `aiohttp` >= 3.5.4
  • `aiohttp-sse` >= 2.0
  • `aiohttp-sse-client` >= 0.2.0
  • `aiokafka` >= 0.6.0
  • `aiostream` >= 0.3.1
  • `asyncpg` >= 0.20.1
  • `beautifulsoup4` >= 4.9.1
  • `boltons` >= 20.1.0
  • `emails` >= 0.5.15
  • `frozendict` >= 1.2
  • `future` >= 0.17.1
  • `gevent` >= 1.3.7
  • `graphviz` >= 0.10.1
  • `ipython` >= 7.0.1
  • `ipydagred3` >= 0.1.5
  • `numpy` >= 1.15.3
  • `pandas` >= 0.19.0
  • `scipy` > 1.2.0
  • `six` >= 1.11.0
  • `socketIO-client-nexus` >= 0.7.6
  • `sympy` >= 1.5.1
  • `temporal-cache` >= 0.0.6
  • `tornado` >= 5.1.1
  • `twilio` >= 6.50.1

Credentials

No credentials are required for the core runtime. Specific I/O sources (Kafka, Postgres, Twilio, SMTP email) require their own credentials — see Environment:1kbgz_Tributary_Streaming_IO_Dependencies.

Quick Install

# Install all required packages
pip install aioconsole>=0.2.1 aiofiles>=0.4.0 aiohttp>=3.5.4 aiohttp-sse>=2.0 \
  aiohttp-sse-client>=0.2.0 aiokafka>=0.6.0 aiostream>=0.3.1 asyncpg>=0.20.1 \
  beautifulsoup4>=4.9.1 boltons>=20.1.0 emails>=0.5.15 frozendict>=1.2 \
  future>=0.17.1 gevent>=1.3.7 graphviz>=0.10.1 ipython>=7.0.1 \
  ipydagred3>=0.1.5 numpy>=1.15.3 pandas>=0.19.0 "scipy>1.2.0" \
  six>=1.11.0 socketIO-client-nexus>=0.7.6 sympy>=1.5.1 \
  temporal-cache>=0.0.6 tornado>=5.1.1 twilio>=6.50.1

Code Evidence

Python version requirement from `setup.py:96`:

python_requires=">=3.7",

Platform-specific event loop from `tributary/streaming/graph.py:84-98`:

def run(self, blocking=True, newloop=False, start=True):
    if sys.platform == "win32":
        # Set to proactor event loop on window
        # (default in python 3.8+)
        loop = asyncio.ProactorEventLoop()
    else:
        if newloop:
            loop = asyncio.new_event_loop()
        else:
            loop = asyncio.get_event_loop()
    asyncio.set_event_loop(loop)
    task = loop.create_task(self._run())

Async graph execution from `tributary/streaming/graph.py:55-66`:

async def _run(self):
    await asyncio.gather(*(asyncio.create_task(s()) for s in self._onstarts))
    while True:
        for level in self._nodes:
            if self._stop:
                break
            await asyncio.gather(*(asyncio.create_task(n()) for n in level))

Common Errors

Error Message Cause Solution
`RuntimeError: Event loop is closed` Event loop closed before graph completes Pass `newloop=True` to `run()` or ensure loop stays alive
`TributaryException: all onstarts and onstops must be async coroutines` Non-async function passed as onstart/onstop Ensure callbacks are `async def` functions
`NotImplementedError` on Windows event loop Default SelectorEventLoop lacks async pipe support Upgrade to Python 3.8+ (ProactorEventLoop is auto-selected)

Compatibility Notes

  • Windows: Requires `ProactorEventLoop` (automatically selected in `graph.py:85`). Python 3.7 users on Windows may need to manually set it.
  • Python 3.7: The minimum supported version. `asyncio.create_task` requires Python 3.7+.
  • Python 3.10+: `asyncio.get_event_loop()` is deprecated; code still uses it but may warn on 3.10+.
  • Jupyter/IPython: The event loop is already running; use `blocking=False` or `run_coroutine_threadsafe`.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment