Skip to content

Monkay

Monkay provides a safe lifecycle layer for Python modules that need lazy imports, settings evaluation, extension orchestration, and context-local mutable state.

At a Glance

  • Lazy imports with configurable caching and deprecation warnings
  • Settings orchestration with runtime evaluation and temporary overrides
  • Extension pipeline with explicit conflict modes (error, keep, replace)
  • Context cages for per-task/per-thread state isolation
  • ASGI helpers for deterministic startup/shutdown integration

Typical Lifecycle

flowchart TD
    A["Import module"] --> B["Monkay(...) wires hooks"]
    B --> C["Application startup"]
    C --> D["evaluate_preloads(...)"]
    D --> E["evaluate_settings(...)"]
    E --> F["set_instance(...)"]
    F --> G["Runtime lazy attribute access"]

Minimal Quickstart

from monkay import Monkay

monkay = Monkay(
    globals(),
    lazy_imports={"json_dumps": "json:dumps"},
)

Continue in Install and first module.

Learning Paths

New to Monkay

  1. Getting Started
  2. Tutorials
  3. Core Concepts

Integrating into an Existing Codebase

  1. Configuration reference
  2. Lazy imports and deprecations
  3. Testing with overrides
  4. Error handling

Running in Production

  1. First production run
  2. Performance and best practices
  3. FAQ and troubleshooting