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.32.tar.gz (84.2 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.32-py3-none-any.whl (22.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastloop-0.1.32.tar.gz
  • Upload date:
  • Size: 84.2 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.32.tar.gz
Algorithm Hash digest
SHA256 752dd0fa7ae915545380a6d9adf9c1ad8f7ae57d924bd92fee90a5c9cfe1e638
MD5 9d82908edaa0ee2776e55eaa7e5d0a93
BLAKE2b-256 98848a09df89e87439eb7763897113104ad243e361f4d3887529d64e64cee2ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fastloop-0.1.32-py3-none-any.whl
  • Upload date:
  • Size: 22.7 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.32-py3-none-any.whl
Algorithm Hash digest
SHA256 b7cb9609978e5f96710a31d9034f5cb0ae6093d7ccd827b62f309c62a9baec9d
MD5 43ed3900467a3c5102b24e9ce291b80d
BLAKE2b-256 6eea1fe59c1d77142e7f3a9880828b8f863b9da802f195206dd1502637cb07f6

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