Skip to main content

and-action

A lightweight Python workflow engine built around persistent state machines. Business logic lives in stage methods on a Process class; the framework handles persistence, scheduling, and state transitions.

Overview

Each process is a class with stage methods. Stages return outcomes that tell the engine what to do next: advance to another stage, sleep until a time, wait for an external event, or end. Process state is persisted to a database between stages, so processes survive restarts and can run across distributed workers.

Installation

pip install and-action

Quick Start

1. Define your process

from datetime import timedelta
from andaction import Process, WaitOn, Event, Timeout

class GreetingProcess(Process):

    def on_start(self):
        print(f"Hello, {self.pinfo.vars['name']}!")
        return self.sleep("on_followup", timedelta(seconds=5))

    def on_followup(self):
        print("Hope you are well.")
        return self.end()

2. Set up the app

import asyncio
from sqlalchemy.ext.asyncio import create_async_engine
from andaction import App
from andaction.db import ProcessRepo

engine = create_async_engine("sqlite+aiosqlite:///myapp.db")
repo = ProcessRepo(engine)

app = App(repo)
app.reg(GreetingProcess)

3. Start a process and run

async def main():
    await repo.initialize()
    await app.start("greeting", vars={"name": "Alice"})
    await app.run()  # starts the scheduler loop

asyncio.run(main())

4. Custom factory (when a process needs dependencies)

import httpx

http = httpx.AsyncClient()

@app.process_factory
def greeting(pinfo) -> GreetingProcess:
    return GreetingProcess(pinfo, http)

Outcomes

Outcome Method Behavior
NextStage self.next("stage_name") Advance to another stage immediately
Sleep self.sleep("stage_name", timedelta) Pause until a timer fires, then resume
WaitOn return WaitOn(Event(...), Timeout(...)) Wait for an external event or timeout
End self.end() Terminate the process

Persistence

ProcessRepo is a SQLAlchemy-backed implementation of the ProcessStorage interface. Pass any custom implementation to App to use a different backend.

class MyStorage(ProcessStorage):
    async def create(self, pinfo): ...
    async def update(self, pinfo): ...
    async def acquire_ready_procs(self, limit=10): ...
    async def acquire_event_proc(self, process_id, event_type): ...
    async def get_by_correlation_id(self, correlation_id): ...

Metadata

Release files for andaction 1.0.0

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

Source distribution (sdist)

Source distribution for andaction 1.0.0
File Size Uploaded Provenance Actions
andaction-1.0.0.tar.gz 21.3 kB With provenance Details for andaction-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for andaction 1.0.0
File Interpreter ABI Platform Actions
andaction-1.0.0-py3-none-any.whl Python 3 none any Details for andaction-1.0.0-py3-none-any.whl

Total release size: 37.1 kB

Release files / andaction-1.0.0.tar.gz

Download URL andaction-1.0.0.tar.gz
Size 21.3 kB
Tags Source
SHA-256 checksum
How to use checksums
68e7d20d6c8b2f9825da16647ef1ba51a36812a57273dd4beae178532c47cc55
BLAKE2b-256 checksum
How to use checksums
37aba4365f4a30019bf4032bba9a2b9369ebef93a67f01a61f9fcd18f0724e57
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 23, 2026.

Transparency log

Release files / andaction-1.0.0-py3-none-any.whl

Download URL andaction-1.0.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d26378a6c36acc66c6e0d6243faad4a2541a14d9e7f54f49be8bb1f8e99a4c60
BLAKE2b-256 checksum
How to use checksums
f23c88f5abe945cb8abb2fec0032d256ff43f01eefdcb6b73d003575abfa4080
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 23, 2026.

Transparency log

Security for andaction 1.0.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for andaction-1.0.0.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 23, 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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 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