Skip to main content

A Python package for deploying stateful loops

Project description

FastLoop

A Python package for building and deploying stateful loops. We use this at beam.cloud to deploy agents.

Installation

pip install fastloop

Usage

Basic Example

from fastloop import FastLoop, LoopContext, LoopEvent

app = FastLoop(name="my-app")

@app.event("user_message")
class UserMessage(LoopEvent):
    user_id: str
    message: str

@app.loop(name="chat", start_event=UserMessage)
async def chat_loop(context: LoopContext):
    user_msg = await context.wait_for(UserMessage, timeout=5.0)
    print(f"User {user_msg.user_id} sent a message: {user_msg.message}")
    
    # Your loop logic here

    # If you want to stop the loop
    context.stop()

    # If you want to pause the loop
    context.pause()

    # By default, we just run it again

if __name__ == "__main__":
    app.run(port=8000)

Development

This project uses uv for dependency management.

# Install dependencies
uv sync

# Run tests
uv run pytest

# Build package
uv build

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastloop-0.1.92.tar.gz (125.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastloop-0.1.92-py3-none-any.whl (46.6 kB view details)

Uploaded Python 3

File details

Details for the file fastloop-0.1.92.tar.gz.

File metadata

  • Download URL: fastloop-0.1.92.tar.gz
  • Upload date:
  • Size: 125.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fastloop-0.1.92.tar.gz
Algorithm Hash digest
SHA256 edaf10c5d61a82e36bdd546ef97f3b112ece8f1e734f1c1b72c31b99faacba0d
MD5 c38c2b9fee2cfc70dc85b887813726ba
BLAKE2b-256 38a9ed487aefe7b7b07ab2d474827851735f1e74bb4289132dea4dfa7b7762b4

See more details on using hashes here.

File details

Details for the file fastloop-0.1.92-py3-none-any.whl.

File metadata

  • Download URL: fastloop-0.1.92-py3-none-any.whl
  • Upload date:
  • Size: 46.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fastloop-0.1.92-py3-none-any.whl
Algorithm Hash digest
SHA256 6c22789c3fef8afed0bf6a70378ab85e4f16d7a5394b55570bd0d429290d9438
MD5 61a5cbaaf5a56dcddfcf95d0bc155d53
BLAKE2b-256 60533b1f3aeaadd745fb78cb2068340fec348b08a0a4f6f816249b472680c701

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page