Metadata-Version: 2.4
Name: neotask
Version: 1.1.1
Summary: NeoTask - 轻量级 Python 异步分布式任务队列，支持即时/延时/周期任务，内置优先级队列、自动重试 | Lightweight Python Async Task Queue Manager
Author-email: neopen <helpenx+task@gmail.com>
Maintainer-email: neopen <helpenx+task@gmail.com>
License: MIT
Project-URL: Homepage, https://task.helpenx.com
Project-URL: Documentation, https://pengline.cn/2026/04/243d5a536d064df59c2ec8668362b8b5
Project-URL: Repository, https://github.com/neopen/neotask
Project-URL: Issues, https://github.com/neopen/neotask/issues
Project-URL: Changelog, https://github.com/neopen/neotask/releases
Project-URL: Author, https://github.com/neopen
Keywords: task-queue,async,asyncio,task-scheduler,job-queue,background-tasks,task-manager,priority-queue,cron,scheduled-tasks,distributed-tasks,worker-pool,任务队列,异步任务,定时任务,任务调度,后台任务,异常恢复,错误重试,优先级队列,周期任务,分布式任务,工作池,嵌入式任务池,分布式任务
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Framework :: AsyncIO
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Distributed Computing
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiosqlite>=0.19.0
Requires-Dist: croniter>=1.0.0
Provides-Extra: ui
Requires-Dist: fastapi>=0.100.0; extra == "ui"
Requires-Dist: uvicorn>=0.23.0; extra == "ui"
Requires-Dist: jinja2>=3.1.0; extra == "ui"
Requires-Dist: python-multipart>=0.0.6; extra == "ui"
Provides-Extra: redis
Requires-Dist: redis<8,>=4.5.0; extra == "redis"
Provides-Extra: sqlite
Requires-Dist: aiosqlite>=0.19.0; extra == "sqlite"
Provides-Extra: monitor
Requires-Dist: psutil>=5.9.0; extra == "monitor"
Provides-Extra: color
Requires-Dist: colorama>=0.4.6; extra == "color"
Provides-Extra: full
Requires-Dist: neotask[color,monitor,redis,sqlite,ui]; extra == "full"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: pytest-timeout>=2.1.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: isort>=5.12.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: build>=1.0.0; extra == "dev"
Requires-Dist: twine>=4.0.0; extra == "dev"
Requires-Dist: cloudpickle; extra == "dev"
Provides-Extra: docs
Requires-Dist: mkdocs>=1.5.0; extra == "docs"
Requires-Dist: mkdocs-material>=9.0.0; extra == "docs"
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "docs"
Dynamic: license-file

<p align="center">
  <h1 align="center">⚡ NeoTask</h1>
  <p align="center">
    <strong>Distributed Task Scheduling System / 轻量级 Python 异步分布式任务队列管理器</strong>
  </p>
  <p align="center">
    <a href="https://www.python.org/" target="_blank"><img src="https://img.shields.io/badge/python-3.8+-3776AB.svg?style=flat-square&logo=python&logoColor=white" alt="Python"></a>
    <a href="./LICENSE"><img src="https://img.shields.io/badge/License-MIT-green.svg?style=flat-square" alt="License"></a>
  </p>
  <p align="center">
    <a href="https://pypi.org/project/neotask/" target="_blank"><img src="https://img.shields.io/pypi/v/neotask.svg?style=flat-square&logo=pypi&logoColor=white" alt="PyPI"></a>
    <a href="https://pepy.tech/project/neotask" target="_blank"><img src="https://img.shields.io/pepy/dt/neotask?style=flat-square&color=blue" alt="Downloads"></a>
    <a href="https://github.com/neopen/neotask" target="_blank"><img src="https://img.shields.io/github/stars/neopen/neotask?style=flat-square&logo=github" alt="GitHub Stars"></a>
  </p>
  <p align="center">
    <a href="https://github.com/neopen/neotask/blob/main/README_zh.md" target="_blank">中文文档</a> •
    <a href="https://task.helpenx.com" target="_blank">Website</a> •
    <a href="https://task.helpenx.com/docs/" target="_blank">Documentation</a> •
    <a href="https://task.helpenx.com/community.html" target="_blank">Community</a> •
    <a href="https://github.com/neopen/neotask/issues/" target="_blank">Issues</a>
  </p>
</p>



> - 🚀 **Lightweight & Async**: Pure Python task queue manager designed for time-consuming jobs (AI generation, video processing, data scraping, etc.)  
> - 📦 **No External Services**: No extra deployment required (no Redis/PostgreSQL needed). and distributed multi-node environment requires Redis support  
> - ⏰ **Flexible Scheduling**: Native support for scheduled, periodic (cron-like), and delayed tasks  
> - ⚡ **Quick Integration**: `pip install neotask` + few lines of configuration



---

## 💡 Why NeoTask?

**NeoTask** is designed to solve async queueing, priority management, and reliable task execution for modern distributed systems and AI pipelines.

| Pain Point | NeoTask Solution |
| :--- | :--- |
| **Task blockage under heavy concurrency** | Priority queueing & task worker pool isolation |
| **Unreliable long-running tasks** | Automatic state persistence, health check & retry mechanism |
| **Complex SDK setup** | Lightweight Pythonic interface with zero friction |



---

## Features

- **No External Services** - Pure Python implementation, no Redis/PostgreSQL required
- **Immediate Tasks** - Supports priority scheduling, high-priority tasks execute first
- **Scheduled Tasks** - Supports delayed execution, fixed intervals, and Cron expressions
- **Asynchronous Concurrency** - Based on asyncio, multi-worker concurrent processing
- **Automatic Retry** - Failed tasks automatically retry with configurable attempts
- **Persistence** - Multiple storage backends: Memory/SQLite/Redis
- **Distributed Support** - Redis shared queue, distributed lock, node heartbeat, and failed-task reclaim
- **Event Callbacks** - Supports task lifecycle event listeners
- **Progress Reporting** - Executors can publish progress updates; subscribers receive `task.progress` events
- **Custom Failure Reason** *(v1.1)* - Executors can mark business-level failures (e.g. `qa_failed`) via `report_failure(reason=...)`; the `task.failed` event carries the reason, distinct from system exceptions
- **Cost Tracking** *(v1.1)* - Executors report tokens / API calls / estimated cost via `report_cost()`; `get_cost_summary()` aggregates per task or across a batch, with mixed currencies flagged as `MIXED`
- **Parent-Child Association** *(v1.1)* - Tasks carry `parent_task_id` with `get_children()` / `get_parent()` queries; auto-aggregation is intentionally left to the caller or orchestrator
- **Checkpoint & Resume** *(v1.1)* - Executors save intermediate state via `save_checkpoint()` / `load_checkpoint()` (or `pool.save_checkpoint(task_id, ...)` for process executors); `task.checkpointed` is emitted, and retries / `resume_from_checkpoint=True` resume from the latest version
- **Local Blackboard** *(v1.1, Memory backend)* - Share process-local values with `context_set()` / `context_get()` / `context_delete()` (optional TTL); non-Memory backends raise `UnsupportedFeatureError` instead of silently degrading



------

## Use Cases

| Scenario | Description | Recommended Configuration | Entry Point |
| :--------------------- | :--------------------------- | :---------------------- | :------------ |
| **AI Text-to-Image/Video Generation** | Queue time-consuming tasks to avoid blocking main flow | `worker_concurrency=3` | TaskPool |
| **Batch File Processing** | Batch operations like transcoding, compression, uploading | `worker_concurrency=10` | TaskPool |
| **Web Scraping Scheduling** | Distributed scraping to prevent being blocked | `storage_type="redis"` | TaskPool |
| **Scheduled Report Sending** | Send daily reports at 9 AM | `cron="0 9 * * *"` | TaskScheduler |
| **Delayed Notifications** | Send reminders 5 minutes after user action | `delay_seconds=300` | TaskScheduler |
| **Heartbeat Detection** | Check service health status every 30 seconds | `interval_seconds=30` | TaskScheduler |
| **Background Data Analysis** | Execute data aggregation tasks at night | `cron="0 2 * * *"` | TaskScheduler |



---

## Architecture & Evolution

```mermaid
graph TB
    subgraph User["User Application Layer"]
        APP[User Code]
    end

    subgraph NeoTask["NeoTask Core"]
        TP[TaskPool<br/>Immediate Task Entry]
        TS[TaskScheduler<br/>Scheduled Task Entry]

        subgraph Core["Shared Core Components"]
            LM[LifecycleManager<br/>Task Lifecycle Management<br/>incl. parent/child fields, custom failure reason]
            QS[QueueScheduler<br/>Priority + Delayed Queue]
            WP[WorkerPool<br/>Worker Pool / Concurrency Control]
            FM[FutureManager<br/>Async Wait / Result Callback]
        end

        subgraph Delivered["v1.1 Local Capability Components (Delivered)"]
            CK[CheckpointRepository<br/>Checkpoint & Resume]
            CT[CostRecorder<br/>Cost & Duration Reporting]
            CS[MemoryContextStore<br/>Local Context (Memory only)]
        end

        subgraph Internal["Internal Components"]
            EB[EventBus<br/>Event Bus]
            MC[MetricsCollector<br/>In-memory Metrics Aggregation]
            LF[LockFactory<br/>Distributed Lock]
        end

        EX[TaskExecutor<br/>User Business Logic]
    end

    subgraph Storage["Storage Layer"]
        MEM[MemoryStorage]
        SQLITE[(SQLiteStorage)]
        REDIS[(RedisStorage)]
    end

    APP -->|Immediate Task| TP
    APP -->|Scheduled Task| TS
    TS -->|Delegates| TP
    TP --> LM
    TP --> QS
    TP --> WP
    TP --> FM

    WP --> EX
    WP --> EB
    WP --> MC
    WP --> LF
    WP -.->|v1.1 delivered| CK
    WP -.->|v1.1 delivered| CT
    WP -.->|v1.1 delivered| CS

    LM --> MEM
    LM --> SQLITE
    LM --> REDIS

    QS --> MEM
    QS --> SQLITE
    QS --> REDIS

    CK -.-> MEM
    CK -.-> SQLITE
    CK -.-> REDIS

    CS -.->|in-memory only, not persisted| MEM

    MC -.->|in-memory only, not persisted| MEM

    LF --> REDIS
```

**Development Roadmap**

> **Note**: v0.1 – v1.0 are released versions; v1.1.0 is released (v1.1.1 is a stability and upgrade-experience patch); v1.2 – v1.3 cover performance, monitoring and reliability. NeoTask is a self-sufficient local execution SDK — DAG decomposition, task dispatch and state progression belong to an upper-layer **control plane** (e.g. NeoFlow), which NeoTask only integrates with as an **execution plane** (pull task → run handler → report event). v2.0 (NeoFlow execution-plane integration) is **deferred**; built-in DAG, dynamic routing, plugin system and Web UI remain out of scope. The task/event wire contract is frozen across 1.x — see [docs/neotask-execution-contract.md](docs/neotask-execution-contract.md).

```mermaid
timeline
    title NeoTask Architecture Evolution Roadmap

    section v0.1
        Basic Task Pool : Local Memory Queue
                        : Async Execution Engine
                        : Memory/SQLite Storage

    section v0.2
        Observability : Event Bus
                      : Metrics Collection
                      : Health Check

    section v0.3
        Scheduled Tasks : Delayed Queue/Time Wheel
                        : Periodic Tasks
                        : Cron Expression

    section v0.4
        Distributed Base : Redis Shared Queue
                         : Distributed Lock

    section v0.5
        Performance Optimization : Prefetch Mechanism
                                : Batch Operations
                                : Connection Pool

    section v1.0
        High Availability : Watchdog Renewal
                          : Timeout Detection
                          : Automatic Fault Recovery

    section v1.1
        Local Capability (Delivered) : Checkpoint & Resume
                                     : Cost Tracking
                                     : Parent-Child Association
                                     : Local Context Store
                                     : Custom Failure Reason

    section v1.2
        Performance & Monitoring : Batch Write Optimization
                                : Query Indexing
                                : Progress Throttling
                                : get_metrics Snapshot
                                : Benchmark Suite

    section v1.3
        Export & Reliability : Prometheus Exporter (optional)
                            : Crash Recovery Boundary
                            : Graceful Shutdown Config
                            : Retry Semantics Unification

    section v2.0
        NeoFlow Execution Plane (Deferred) : Task Consumer (pull)
                                          : Remote Event Reporting
                                          : Control Message Handling
                                          : Reuse Node & Heartbeat Registry
```

------

## Quick Start

### Installation

**Requirements**: Python ≥ 3.8. The base package depends on `aiosqlite` (SQLite storage) and `croniter` (Cron expressions); Redis, psutil, and the Web UI are optional extras.

```sh
# Basic installation
pip install neotask

# With Redis distributed support
pip install neotask[redis]

# Full installation
pip install neotask[full]
```



### Immediate Tasks (TaskPool)

```python
from neotask import TaskPool

async def process(data):
    return {"result": "done", "data": data}

# Create task pool
pool = TaskPool(executor=process)

# Submit task
task_id = pool.submit({"id": 123})

# Wait for result
result = pool.wait_for_result(task_id)

pool.shutdown()
```

### Scheduled Tasks (TaskScheduler)

```python
from neotask import TaskScheduler

scheduler = TaskScheduler(executor=process)

# Execute after 60 seconds delay
scheduler.submit_delayed({"id": 123}, delay_seconds=60)

# Execute every 5 minutes
scheduler.submit_interval({"id": 123}, interval_seconds=300)

# Execute daily at 9 AM
scheduler.submit_cron({"id": 123}, "0 9 * * *")

scheduler.shutdown()
```

### Using Context Manager

```python
with TaskPool(executor=process) as pool:
    task_id = pool.submit({"id": 123})
    result = pool.wait_for_result(task_id)
```

### Using Event Callbacks

```python
from neotask import TaskPool

async def on_task_created(event):
    print(f"Task created: {event.task_id}")

async def on_task_completed(event):
    print(f"Task completed: {event.task_id}, Result: {event.data}")

async def on_task_failed(event):
    print(f"Task failed: {event.task_id}, Error: {event.data}")

pool = TaskPool(executor=my_executor)
pool.start()

# Register event callbacks
pool.on_created(on_task_created)
pool.on_completed(on_task_completed)
pool.on_failed(on_task_failed)

task_id = pool.submit({"test": "event"})
result = pool.wait_for_result(task_id)
```

### Reporting Task Progress

Call `report_progress()` inside an async executor (or `report_progress_sync()` in a
thread executor) to publish progress updates; subscribe with `pool.on_progress()`:

```python
from neotask import TaskPool, report_progress

async def transcode(data):
    await report_progress(0.2, "probing")
    # ... do the work ...
    await report_progress(0.8, "encoding")
    return {"ok": True}

async def on_progress(event):
    print(f"{event.task_id}: {event.data['progress']:.0%} {event.data['message']}")

pool = TaskPool(executor=transcode)
pool.on_progress(on_progress)
pool.start()
task_id = pool.submit({})
pool.wait_for_result(task_id)
```

Progress is also persisted on the task record (`get_task(task_id)["progress"]`) and
set to `1.0` when the task succeeds. Reporting outside a task execution context is
a safe no-op (returns `False`).

### Quick Performance Check

Official benchmarks only describe one machine with one set of parameters. The fastest
way to answer "will this perform well for my workload?" is to run your own executor
locally:

```bash
# Sanity check with the built-in 5ms demo executor
python -m neotask.benchmark --tasks 200 --concurrency 8 --warmup 10

# Use a real executor: module:func or path.py:func (Windows absolute paths supported)
python -m neotask.benchmark --executor my_tasks:handle --tasks 500 --concurrency 16

# Machine-readable output for scripts / CI comparisons
python -m neotask.benchmark --executor my_tasks:handle --json
```

You can also use the unified entry point `neotask --benchmark` (available after
installation, same parameters) or `python -m neotask --benchmark`. The report lists
the task count, concurrency, warmup, timeout, prefetch, storage, executor mode, and
task data template used for this run.

You can also call it from code (`run_benchmark_async` in async code, `run_benchmark`
in plain scripts):

```python
from neotask.benchmark import run_benchmark_async

result = await run_benchmark_async(my_executor, tasks=300, concurrency=8)
print(result.format())        # result.to_dict() is JSON-serializable
```

How the numbers are measured:

- Latency is end-to-end `created_at -> completed_at` (including queueing), computed
  over successful tasks only; p50/p95/p99 show the tail.
- Throughput = (succeeded + failed) / total duration; failures are counted
  separately and `max_retries=0` avoids retry amplification.
- The run always uses memory storage and disables health checks / metrics / reporter,
  so only the task execution path is measured.
- Synchronous executors are automatically run in a thread pool (reported as
  `thread`), so they do not block the worker event loop.
- Results reflect the current machine and parameters only. When comparing, keep
  `--tasks` / `--concurrency` / `--payload` identical and add `--warmup` to skip the
  initial idle backoff.



## API Reference

| Method                                                       | Description                                                  |
| :----------------------------------------------------------- | :----------------------------------------------------------- |
| `pool.submit(data, priority=2, delay=0)`                     | Submit task                                                  |
| `pool.submit_batch(tasks, priority=2, partial_on_error=False)` | Submit a batch of tasks (all-or-nothing by default; pass `partial_on_error=True` to tolerate partial failures — see [Batch submission semantics](#batch-submission-semantics)) |
| `pool.wait_for_result(task_id, timeout=300)`                 | Wait for result                                              |
| `pool.get_status(task_id)`                                   | Get status                                                   |
| `pool.cancel(task_id)`                                       | Cancel task                                                  |
| `pool.task_exists(task_id)`                                  | Check whether a task id is taken (idempotent resubmit)       |
| `pool.report_failure(task_id, reason, detail="")`            | Fail a running task with a business reason (skips auto-retry) |
| `pool.submit(data, parent_task_id=parent_id)`                | Submit a child task associated with a parent                 |
| `pool.get_children(task_id)` / `pool.get_parent(task_id)`    | Query the parent-child relation                              |
| `pool.report_cost(task_id, tokens_in=0, tokens_out=0, api_calls=0, estimated_cost=None, currency=None)` | Add cost usage to a task and emit `task.cost_reported` |
| `pool.get_cost_summary(task_ids=None)`                       | Aggregate cost across selected tasks or all tasks             |
| `pool.save_checkpoint(task_id, state) / pool.load_checkpoint(task_id)` | Explicit checkpoint write / latest-state read (works for process executors) |
| `pool.submit(..., task_id=..., resume_from_checkpoint=True)` | Resubmit with an external id and inject its latest checkpoint |
| `pool.context_set(key, value, ttl=None) / context_get(key) / context_delete(key)` | Process-local blackboard (Memory backend only) |
| `pool.on_progress(handler)`                                  | Subscribe to progress events                                 |
| `scheduler.submit_delayed(data, delay_seconds)`              | Delayed task                                                 |
| `scheduler.submit_interval(data, interval_seconds)`          | Periodic task                                                |
| `scheduler.submit_cron(data, cron_expr)`                     | Cron task                                                    |

Detailed API documentation can be found [here](https://task.helpenx.com/docs/api-reference.html)

### Batch submission semantics

`submit_batch` is **all-or-nothing** by default: if any task fails to serialize,
persist, or enqueue, the whole batch is rolled back and `BatchSubmitError` is
raised with the failing index and root cause.

Pass `partial_on_error=True` to tolerate partial failures:

```python
result = pool.submit_batch(tasks, partial_on_error=True)
print(result.succeeded)  # task_ids that were actually submitted
print(result.failed)     # [{"index": 3, "data": {...}, "error": "queue is full"}]
```

`BatchSubmitResult` is iterable and sized like `succeeded` for backward compatibility.



## Usage Notes

A few behaviors are easy to trip over, so they are documented explicitly:

- **`get_result` vs `wait_for_result`**: `wait_for_result(task_id)` returns the
  executor's raw value, while `get_result(task_id)` returns a metadata wrapper
  dict `{task_id, status, result, error, failure_reason, parent_task_id,
  estimated_cost, cost_tracking, queue_wait_ms, duration_ms, created_at,
  completed_at}` — the real payload is under `result`.
- **Cost reporting**: call `neotask.report_cost(tokens_in=..., tokens_out=...,
  api_calls=..., estimated_cost=..., currency="USD")` inside the executor; use
  `pool.report_cost(task_id, ...)` for process executors or usage that arrives
  after the task finished. Repeated reports accumulate. When a task reports a
  cost, the `task.completed` event `data` becomes `{"result": ..., "cost": {...}}`;
  without a cost it stays the raw result.
- **Business failure vs exception**: a task that fails because the *business*
  said so (review rejected, risk score too low) should report a reason instead
  of raising, so it doesn't burn the retry budget. Call
  `neotask.report_failure("qa_failed", "score=10")` inside the executor and
  return normally — NeoTask finalizes the task as `FAILED` with
  `failure_reason="qa_failed"`, keeps `retry_count` at 0, and puts `reason` on
  the `task.failed` event. From outside the executor use
  `pool.report_failure(task_id, reason)`, which only accepts a running task.
  Raising an exception keeps the existing retry + dead-letter behaviour.
- **Event keys**: lifecycle event types are namespaced as `task.created` /
  `task.started` / `task.completed` / `task.failed` / `task.cancelled` / `task.retry`
  (not bare `created`). Prefer the `pool.on_completed(...)` helpers, or subscribe
  with the `EventType` constants (`from neotask import EventType`).
- **Checkpoint & resume**: inside async executors call
  `await neotask.save_checkpoint(state)` / `await neotask.load_checkpoint()`;
  thread executors use the `_sync` variants; process executors must use
  `pool.save_checkpoint(task_id, state)` / `pool.load_checkpoint(task_id)`.
  Automatic and manual retries inject the latest checkpoint into
  `task.data["__checkpoint__"]`; pass `resume_from_checkpoint=True` to
  `submit` / `create_pending_task` (requires an explicit `task_id`). Versions are
  pruned to `checkpoint_keep_versions` (default 5), reflected in
  `get_task()["checkpoint_version"]`, and every write emits `task.checkpointed`.
- **Local blackboard**: `context_set` / `context_get` / `context_delete` are
  process-local and **Memory backend only**. SQLite / Redis raise
  `UnsupportedFeatureError` instead of silently doing nothing.
- **Graceful shutdown scope**: `shutdown(graceful=True)` drains tasks that are
  already enqueued (pending + running) before returning. Unexpired delayed
  tasks and periodic/cron schedules are **not** fired during shutdown — cancel
  periodic schedules first (`cancel_periodic`) or use `graceful=False` for an
  immediate return.
- **Crash / restart recovery**: auto-recovery re-runs tasks that were already
  **enqueued** (their ids live in the persisted queue). A record created only via
  `create_pending_task()` and never pushed through `enqueue_task()` is not part
  of the queue, so it will **not** auto-run after a restart — enqueue it explicitly.
- **Upgrading a 1.0.x SQLite database**: new columns and the
  `task_checkpoints` table are created during `start()` (concurrent-start safe);
  startup failures are raised immediately instead of surfacing on the first task.
  To backfill `queue_wait_ms` / `duration_ms` for historical rows and
  build the parent index, stop the pool and run
  `python scripts/migrate_task_metadata.py --db <path> --apply` (preview without
  `--apply`).
- **Periodic task persistence**: `enable_persistence` is **on by default**. With
  `storage_type="sqlite"` or `"redis"`, interval / cron periodic tasks are persisted
  and auto-restored after a restart; slots missed while down are handled by each
  task's `missed_policy`. With `storage_type="memory"` or
  `enable_persistence=False` the schedule cannot survive a restart — NeoTask emits
  a one-time warning when a periodic task is registered in such a configuration
  instead of losing it silently.
- **Minimum interval granularity**: periodic tasks are driven by a scan loop with
  `SchedulerConfig.scan_interval` (default `1.0s`). `submit_interval` with an
  interval smaller than `scan_interval` may skip fires; lower `scan_interval` or
  enable the time wheel (`enable_time_wheel=True`) for finer granularity.
- **Cross-node waiting**: `wait_for_result` / `wait_for_result_async` work for
  tasks executed on another node — the wait uses future notification plus a
  low-frequency repository check, so a result persisted by a remote worker is
  picked up without waiting for the full timeout.


## Configuration Example

```python
from neotask import TaskPool, TaskPoolConfig

config = TaskPoolConfig(
    worker_concurrency=10,      # Number of concurrent workers
    max_retries=3,              # Number of retries
    storage_type="sqlite",      # Storage type
)

pool = TaskPool(executor=process, config=config)
```

Detailed usage examples can be found [here](https://task.helpenx.com/docs/configuration.html)



## Contribution Guide

### Setting Up Development Environment

```sh
# Clone repository
git clone https://github.com/neopen/neotask.git
cd neotask

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/

# View test coverage
pytest --cov=src/neotask tests/

# Run specific module tests
pytest tests/test_task_pool.py -v
pytest tests/test_task_scheduler.py -v
```



### Contribution Workflow

Welcome to submit Issues and Pull Requests

1. Fork the project
2. Create a feature branch (`git checkout -b feature/amazing`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push branch (`git push origin feature/amazing`)
5. Submit Pull Request

### Code Style

- Follow [PEP 8](https://peps.python.org/pep-0008/) code style
- Add appropriate [type annotations](https://peps.python.org/pep-0484/)
- Write unit tests for new features (coverage ≥ 80%)
- Update relevant documentation and example code
- Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/)


## Issue Reporting

- **Submit Issue**: https://github.com/neopen/neotask/issues
- **Feature Suggestions**: Use Enhancement label
- **Bug Reports**: Use Bug label and provide reproduction steps
- **Security Vulnerabilities**: Please send email directly to the author's email

------

## License

MIT License © 2026 neopen

------

## Acknowledgments

Thanks to all contributors and the open source community for their support.

------

## Contact

- GitHub：https://github.com/neopen/neotask
- Email：helpenx@gmail.com
- Docs：https://task.helpenx.com/docs/
- Blog: https://pengline.cn/
