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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file temporalloop-0.2.1.tar.gz.
File metadata
- Download URL: temporalloop-0.2.1.tar.gz
- Upload date:
- Size: 142.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a9b4cdab2c89c4edb77bbc2296077654c5d8ad563e0b35adab95103c2e5a2a71
|
|
| MD5 |
3f32f5b740a90fffa5c2c4f326d1006a
|
|
| BLAKE2b-256 |
c3add30fd1e37aeeffa6af81275443453167dc6746b8e2073afdcf89d57662f1
|
File details
Details for the file temporalloop-0.2.1-py3-none-any.whl.
File metadata
- Download URL: temporalloop-0.2.1-py3-none-any.whl
- Upload date:
- Size: 23.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aac4627def4c2f34750b5241e897ad892df7bde98266bf312bd263a9488c0c6b
|
|
| MD5 |
0ab61ec04bb72648905164206154810b
|
|
| BLAKE2b-256 |
8595eeb581ec1c95979383ce36c3e0d95b80dfa18273deeb362e86e2ecf30fb4
|