Huey: A Lightweight Python Task Queue for Redis, SQLite, and More

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Huey: A Lightweight Python Task Queue for Redis, SQLite, and More

Summary

Huey is a lightweight and simple Python task queue designed for various storage backends like Redis, SQLite, or in-memory. It provides a clean API for scheduling tasks, retrying failures, managing recurring jobs, and executing them efficiently across multiple processes, threads, or greenlets. This library offers a robust solution for asynchronous task management in Python applications.

Repository Information

Analyzed by OSRepos on February 17, 2026

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

Huey is a lightweight and simple task queue written in Python, designed to handle asynchronous tasks efficiently. It offers a clean and straightforward API, making it easy to integrate into your Python applications. Huey supports various storage backends, including Redis, SQLite, file-system, or even in-memory, providing flexibility for different project requirements.

Key features of Huey include multi-process, multi-thread, or greenlet task execution models, allowing you to choose the best concurrency strategy for your workload. It enables scheduling tasks to execute at a given time or after a delay, and supports recurring tasks similar to a crontab. Huey also provides mechanisms for automatically retrying failed tasks, task prioritization, result storage, expiration, and locking, along with task pipelines and chains for complex workflows.

Installation

To get started with Huey, you can install it using pip:

pip install huey

Depending on your chosen storage backend, you might need to install additional dependencies, for example, redis for Redis storage.

Examples

Here are some basic examples demonstrating how to define tasks, call them, and run the Huey consumer.

Defining and Calling a Task:

First, initialize Huey with your preferred storage backend, such as Redis:

from huey import RedisHuey, crontab

huey = RedisHuey('my-app', host='redis.myapp.com')

@huey.task()
def add_numbers(a, b):
    """A simple task to add two numbers."""
    return a + b

@huey.task(retries=2, retry_delay=60)
def flaky_task(url):
    """This task might fail and will be retried up to 2 times with a 60s delay."""
    # Assume this_might_fail is a function that can raise an exception
    return this_might_fail(url)

@huey.periodic_task(crontab(minute='0', hour='3'))
def nightly_backup():
    """A task that runs every night at 3 AM."""
    sync_all_data() # Assume sync_all_data performs a backup

Calling a task-decorated function enqueues the function call for execution by the consumer. A special result handle is returned immediately, which can be used to fetch the result once the task is finished:

# Assuming 'add_numbers' is defined in a module like 'demo.py'
from demo import add_numbers

res = add_numbers(1, 2)
print(f"Task enqueued, result handle: {res}")

# To get the result (this will block until the task is complete)
result = res()
print(f"Task result: {result}") # Output: Task result: 3

Scheduling Tasks for Future Execution:

Tasks can also be scheduled to run in the future, either after a delay or at a specific time:

# Schedule 'add_numbers' to run in approximately 10 seconds
res_scheduled = add_numbers.schedule((2, 3), delay=10)
print(f"Task scheduled, result handle: {res_scheduled}")

# Block until the scheduled task finishes (after ~10 seconds)
scheduled_result = res_scheduled(blocking=True)
print(f"Scheduled task result: {scheduled_result}") # Output: Scheduled task result: 5

Running the Huey Consumer:

The Huey consumer is responsible for picking up and executing the enqueued tasks. You can run it with different worker models:

To run the consumer with four worker processes:

huey_consumer.py my_app.huey -k process -w 4

To run the consumer with a single worker thread (default):

huey_consumer.py my_app.huey

For IO-bound workloads, you might prefer greenlets due to their lightweight nature:

huey_consumer.py my_app.huey -k greenlet -w 32

Why Use Huey?

Huey stands out as an excellent choice for managing asynchronous tasks in Python due to several compelling reasons:

  • Lightweight and Simple API: It is designed to be a lightweight alternative to more complex task queues, offering a clean and intuitive API that makes task definition and management straightforward.
  • Flexible Storage Options: With built-in support for Redis, SQLite, file-system, and in-memory storage, Huey provides versatility, allowing you to choose the backend that best fits your project's infrastructure and scale.
  • Robust Feature Set: Beyond basic task execution, Huey includes advanced features like scheduled and recurring tasks, automatic retries for transient failures, task prioritization, result storage, expiration, and locking, covering a wide range of asynchronous processing needs.
  • Scalable Concurrency Models: It supports various execution models, including multi-process, multi-thread, and greenlet workers, enabling you to optimize performance based on the nature of your tasks (CPU-bound vs. IO-bound).
  • Pythonic Design: Written entirely in Python, Huey integrates seamlessly into existing Python projects, leveraging decorators for task definition and providing a familiar development experience.

Links

Related repositories

Similar repositories that may be relevant next.

ChatArena: Multi-Agent Language Game Environments for LLMs

ChatArena: Multi-Agent Language Game Environments for LLMs

July 1, 2026

ChatArena is a Python library designed to provide multi-agent language game environments for Large Language Models (LLMs), aiming to foster the development of communication and collaboration capabilities in AI. It offers a flexible framework for defining players, environments, and interactions based on Markov Decision Processes. Please note that as of August 11, 2025, this project has been deprecated due to a lack of widespread community use and is no longer receiving updates or support.

AILarge Language ModelsMulti-Agent Systems
Agentarium: A Python Framework for AI Agent Simulations

Agentarium: A Python Framework for AI Agent Simulations

July 1, 2026

Agentarium is an open-source Python framework designed for creating and managing simulations with AI-powered agents. It offers an intuitive platform for designing complex, interactive environments where agents can act, learn, and evolve. This powerful tool simplifies the orchestration of multiple AI agents and their interactions.

PythonAIAgents
Lighteval: Your All-in-One Toolkit for LLM Evaluation

Lighteval: Your All-in-One Toolkit for LLM Evaluation

July 1, 2026

Lighteval is a comprehensive toolkit from Hugging Face for evaluating Large Language Models (LLMs) across various backends. It enables users to dive deep into model performance by saving detailed, sample-by-sample results and supports over 1000 evaluation tasks. The framework offers extensive customization options, allowing users to create custom tasks and metrics tailored to their specific needs.

evaluationevaluation-frameworkevaluation-metrics
PromptBench: A Unified Framework for LLM Evaluation and Robustness

PromptBench: A Unified Framework for LLM Evaluation and Robustness

July 1, 2026

PromptBench is a comprehensive Python library designed for the evaluation and understanding of Large Language Models (LLMs). It provides a unified framework for assessing model performance, exploring various prompt engineering techniques, and evaluating robustness against adversarial attacks. This tool empowers researchers to conduct in-depth analyses of LLMs across diverse datasets and models.

large-language-modelsLLM Evaluationprompt-engineering

Source repository

Open the original repository on GitHub.

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️