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.

awesome-cli-coding-agents: A Curated Directory of Terminal-Native AI Tools

awesome-cli-coding-agents: A Curated Directory of Terminal-Native AI Tools

August 9, 2026

The `awesome-cli-coding-agents` repository offers a comprehensive, curated directory of over 100 terminal-native AI coding agents. These powerful tools operate directly within your command line, enabling autonomous code reading, editing, and execution. The list also covers various harnesses and orchestration solutions for managing these agents.

AICLICoding Agents
QwenPaw: Your Personal AI Assistant for Local and Cloud Deployment

QwenPaw: Your Personal AI Assistant for Local and Cloud Deployment

August 7, 2026

QwenPaw is a powerful personal AI assistant designed for easy installation and deployment, either on your local machine or in the cloud. It supports multiple chat applications and offers highly extensible capabilities, making it a versatile tool for various AI-driven tasks. With its robust memory system and security features, QwenPaw aims to be an intuitive and private partner in your digital life.

agentai-agentchatbot
DeepTutor: Lifelong Personalized Tutoring with AI Agents

DeepTutor: Lifelong Personalized Tutoring with AI Agents

August 7, 2026

DeepTutor is an advanced AI-powered platform designed for lifelong personalized tutoring, integrating various learning modes into a single, extensible system. It leverages large language models and multi-agent systems to offer features like interactive chat, quiz generation, and skill development. This project provides a comprehensive environment for learners and educators seeking intelligent, adaptive educational tools.

AITutoringLLM
Memori: Agent-Native Memory Infrastructure for LLM Production Systems

Memori: Agent-Native Memory Infrastructure for LLM Production Systems

August 6, 2026

Memori provides agent-native memory infrastructure, offering an LLM-agnostic layer that transforms agent execution and conversations into structured, persistent state. Designed for enterprise use, it seamlessly integrates with existing data infrastructure and supports various deployment environments, ensuring robust memory management for AI agents.

agent-memoryLLMAI

Source repository

Open the original repository on GitHub.

10 counted GitHub visits

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 ❤️