Skip to main content

pyfiq

pyfiq is a minimal Redis-backed FIFO task queue for Python. It lets you decorate functions with @fifo(...), and they'll be queued for execution in strict order processed by threaded background workers utilizing Redis BLPOP.

It's for I/O-bound tasks like HTTP requests, webhook dispatching, or syncing with third-party APIs--especially when execution order matters, but you don't want the complexity of Celery or external workers.

Unlike:

  • Celery, which requires brokers, workers, and doesn't preserve ordering by default
  • AWS Lambda, which don't guarantee FIFO unless using with SQS FIFO + extra setup

pyfiq is:

  • Embedded: runs inside your application process (no separate worker service)
  • Application-scaled & distributed: queues are processed wherever your app runs
  • Order-preserving: per-queue FIFO with one active consumer per queue
  • Zero-config: no external orchestrators, brokers, or setup required

It's designed to be very simple, and only provide ordered execution of tasks. The code is rudimentary right now, and there's a lot of room for improvement.

Important #1

This library is intended only for I/O-bound tasks. Using it with CPU-bound code is not recommended, as it runs in a background thread and would block execution.

Important #2

This project is in its early stages of development.

Quick start

Installing

$ pip install pyfiq

Bootstrap the worker

This should run once on application startup, typically in your main thread or service entrypoint:

from pyfiq import threaded_worker, RedisQueueBackend

worker = threaded_worker(
    backend=RedisQueueBackend("redis://localhost")
)

This starts a background worker thread that consumes tasks from Redis.

Decorate your functions

Decorate the functions you want to be processed asynchronously in a FIFO queue:

import requests
from pyfiq import fifo

@fifo(queue="http-requests1")
def fetch_google():
    requests.get("https://google.com")

@fifo(queue="http-requests1")
def fetch_microsoft():
    requests.get("https://microsoft.com")

@fifo(queue="http-requests2")
def fetch_github():
    requests.get("https://github.com")

Todo

Redis / pyfiq Core Logic

  • Graceful shutdown: Ensure background thread stops cleanly (e.g. via signal handlers or context managers)
  • Error handling & logging: Catch and log exceptions inside task execution without crashing the worker
  • Retry support: Optional retries on failure, ideally with configurable delay or retry queue
  • Task deduplication (optional): Prevent duplicate enqueues via Redis keys or hashes
  • Task expiration / TTL: Option to discard stale tasks (use Redis TTL or ZSET-based queues if needed)
  • Custom serialization support: Allow override of default JSON serializer (e.g., for datetime, Decimal)
  • Connection pool support: Reuse Redis connections across queues and workers
  • Support for async decorators (optional): Allow @fifo to be used on async def functions (using asyncio.to_thread etc.)

Testing & Reliability

  • Unit tests: Cover queue backend, task dispatch, decorator behavior
  • Simulate concurrent enqueuers across instances

CI/CD Pipeline

  • GitHub Actions
  • Run tests on push & PR
  • PyPI publishing on version push tag
  • Automatic PyPI publish (publish.yml GA):

Download files

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

Source Distribution

pyfiq-0.1.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

pyfiq-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file pyfiq-0.1.1.tar.gz.

File metadata

  • Download URL: pyfiq-0.1.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.10

File hashes

Hashes for pyfiq-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e1bed8a414e4d9a3631382b3bfe929f59bb1e3594dec92a249c35ad0e312c9c9
MD5 da9c737d10dcf8bc43cdac18e86d82a3
BLAKE2b-256 450b841b4804292ebb982a4d67216c841c0442e63b886eb8795ef5c699eac904

See more details on using hashes here.

File details

Details for the file pyfiq-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pyfiq-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.10

File hashes

Hashes for pyfiq-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fd52cb376165038dde20ad548caa8fe2c2b32001c61819e64aaa750c3946eebc
MD5 5d1e0466295044f06641045d3ee411a9
BLAKE2b-256 c5ec098fc91eab45b22b6862d2f23556b0c32f80fe646b242bb8e157ef664843

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page