Skip to main content

Adaptive Executor

Adaptive thread pool executor that scales concurrency based on policies.

Features

  • Time-based scaling
  • CPU & memory criteria
  • Multi-criterion aggregation
  • Graceful shutdown

Installation

Minimal Installation (Core Only)

pip install adaptive-executor

Feature-Specific Installations

# Time-based scaling only
pip install adaptive-executor[time]

# CPU/Memory monitoring only
pip install adaptive-executor[cpu]

# Complete feature set (recommended)
pip install adaptive-executor[standard]

# Development with all tools
pip install adaptive-executor[dev]

Quick Start

from adaptive_executor import AdaptiveExecutor, MultiCriterionPolicy
from adaptive_executor.criteria import TimeCriterion, CpuCriterion
from datetime import time

# Create scaling criteria
time_policy = TimeCriterion(
    worker_count=8,
    active_start=time(22, 0),
    active_end=time(6, 0),
    timezone="UTC",
)
cpu_policy = CpuCriterion(threshold=75, workers=4)

# Combine criteria
policy = MultiCriterionPolicy([time_policy, cpu_policy], hard_cap=10)

# Create and use executor
executor = AdaptiveExecutor(max_workers=15, policy=policy)

# Submit tasks
def my_task(task_id):
    print(f"Processing task {task_id}")

for i in range(5):
    executor.submit(my_task, i)

executor.join()
executor.shutdown()

Development Setup

This project uses setuptools with a src/ package layout (src/adaptive_executor).

git clone https://github.com/Teut2711/adaptive-executor.git
cd adaptive-executor
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate
pip install -e ".[dev]"

Logging Configuration

The adaptive-executor provides comprehensive logging that can be configured to suit your needs. By default, it logs to the console with INFO level.

Basic Logging Control

from adaptive_executor import setup_logger

# Disable all logging
setup_logger(level=logging.CRITICAL)

# Or set a specific log level
import logging
setup_logger(level=logging.WARNING)  # Only show warnings and above

Advanced Logging Configuration

You can also configure file logging with rotation:

# Configure file logging with rotation (10MB per file, keep 5 backups)
setup_logger(
    level=logging.DEBUG,
    log_file="/var/log/adaptive_executor.log",
    max_bytes=10*1024*1024,  # 10MB
    backup_count=5
)

Environment Variables

You can control logging via environment variables:

# Set log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
ADAPTIVE_EXECUTOR_LOG_LEVEL=WARNING

# Enable file logging
ADAPTIVE_EXECUTOR_LOG_FILE=/path/to/logfile.log

# Set max log file size (in bytes)
ADAPTIVE_EXECUTOR_LOG_MAX_BYTES=10485760  # 10MB

# Set number of backup files to keep
ADAPTIVE_EXECUTOR_LOG_BACKUP_COUNT=5

Disabling Logging Completely

To completely disable all logging:

import logging
logging.getLogger('adaptive_executor').addHandler(logging.NullHandler())
logging.getLogger('adaptive_executor').propagate = False

Documentation

Full documentation is available at https://Teut2711.github.io/adaptive-executor

License

MIT License - see LICENSE file for details.

Metadata

Release files for adaptive-executor 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for adaptive-executor 0.1.1
File Size Uploaded Provenance
adaptive_executor-0.1.1.tar.gz 23.2 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for adaptive-executor 0.1.1
File Interpreter ABI Platform
adaptive_executor-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 44.0 kB

Release files / adaptive_executor-0.1.1.tar.gz

Download URL adaptive_executor-0.1.1.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ee27adbc6ff626fbda9d5d46d66fc0d22e52bc829fc6d0713addd54093c6299e
BLAKE2b-256 checksum
How to use checksums
c8ce3ffb501aa4c7fc49ad79e8f8f6a75470e52fd80c7c10f907548b6f55dd5c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.

Transparency log

Release files / adaptive_executor-0.1.1-py3-none-any.whl

Download URL adaptive_executor-0.1.1-py3-none-any.whl
Size 20.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a53568352a49eea34b9866a95693cd130d5b27778be1b44623e25cc45c9f492
BLAKE2b-256 checksum
How to use checksums
3fa408ec9a5ba6c0e8132f06f2717fd3465520fe08720d654e76d8d39ca1c74a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.

Transparency log

Security for adaptive-executor 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for adaptive_executor-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page