Skip to main content

No project description provided

Project description

TemporalLoop

TemporalLoop is an open-source project that helps you run and manage Temporal.io workers. It Inspired from how uvicorn works for ASGI applications. With a simple configuration, you can define multiple workers with their own activities, workflows, queue and settings. It aims to reduce boilerplate code, improve worker management, and increase interoperability between Temporal-based projects.

Features

  • Easy configuration with YAML or JSON
  • Unify and Simplified worker maintenance across all Temporal's python microservices
  • Customizable logging
  • Support for DataConverter and Interceptor classes
  • Customizable Worker instance
  • Launch multiple workers on a single process
  • Signal handling (SIGINT, SIGTERM) with graceful shutdown

Prerequisites

  • Python 3.10+
  • Temporal.io server (self-hosted or cloud)

Installation

Install TemporalLoop using pip:

pip install temporalloop

Configuration

Here's a sample config.yaml for configuring TemporalLoop:

temporalio:
  host: "127.0.0.1:7233"
  namespace: "default"

logging:
  level: "info"
  use_colors: true
  log_config: "path/to/your/log_config.ini"

workers:
  - name: "worker1"
    queue: "first-queue"
    workflows:
      - "your_package.workflows:YourWorkflow"
    activities:
      - "your_package.activities:your_activity_one"
      - "your_package.activities:your_activity_two"

  - name: "worker2"
    queue: "another-queue"
    workflows:
      - "your_package.workflows:YourWorkflow"
    activities:
      - "your_package.activities:your_activity_one"
      
    # Settings can be overrided per worker
    namespace: "staging" 
    interceptors: []  # Skip interceptors for this worker
    factory: "your_package.worker:WorkerFactory"
    
interceptors:
  - "temporalloop.interceptors.sentry:SentryInterceptor"

This sample configuration file includes:

  • Temporal settings, including the host and namespace
  • Logging settings, such as the log level, color usage, and an optional log configuration file
  • A list of workers, each with a unique name, task queue, and associated workflows and activities, namespace
  • A list of interceptors to be used across all workers

Replace your_package with your actual package name and provide the appropriate paths for your workflows, activities, and interceptors.

Usage

Starting a Worker

You can start a worker either by writing a script or using the command-line interface.

Command-Line Example

tempoloop --config=config.yaml --host=localhost:7233 --log-level=debug

Script Example

# worker.py
from temporalloop.config import Config, WorkerConfig
from temporalloop.main import run

from your_package.workflows import YourWorkflow
from your_package.activities import your_activity_one, your_activity_two

if __name__ == "__main__":
    run(Config(
        host="localhost:7233",
        workers=[
            WorkerConfig(name="worker1",
                         queue="your-queue",
                         workflows=[YourWorkflow],
                         activities=[your_activity_one, your_activity_two],
                         ),
            WorkerConfig(name="worker2",
                         queue="another-queue",
                         workflows=[YourWorkflow],
                         activities=[your_activity_one, your_activity_two],
                         ),
        ],        
    ))

Run the script with

python worker.py

Project details


Download files

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

Source Distribution

temporalloop-0.2.2.tar.gz (138.2 kB view details)

Uploaded Source

Built Distribution

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

temporalloop-0.2.2-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file temporalloop-0.2.2.tar.gz.

File metadata

  • Download URL: temporalloop-0.2.2.tar.gz
  • Upload date:
  • Size: 138.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.28

File hashes

Hashes for temporalloop-0.2.2.tar.gz
Algorithm Hash digest
SHA256 fd054a1e500008d98a37626fc0c3009c194d9d8f72cc57479425ef2c4f2b9dac
MD5 17afe4f850ef186c51445eb917262538
BLAKE2b-256 799e472c9919bffe882cb2e9b318010db7a0c84712094b1247ed8201cb9881b3

See more details on using hashes here.

File details

Details for the file temporalloop-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for temporalloop-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f01d7f26b5e18e520bf3b2a98764f40a381796b4fc3e38098ffb7973a96b9b2
MD5 9de344cfa692f16b861b016ff3e9c20f
BLAKE2b-256 fe80a5acccb81e8ae59d35b93c2cd3d6eb82f7c481370e1f24559290ac1cacde

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