Release v0.0.17. (Installation)

Spinach is a Redis task queue for Python 3 heavily inspired by Celery and RQ.

Distinctive features:

  • Threaded and asyncio workers
  • At-least-once or at-most-once delivery per task
  • Periodic tasks without an additional process
  • Concurrency limits on queued jobs
  • Scheduling of tasks in batch
  • Embeddable workers for easier testing
  • Integrations with Flask, Django, Logging, Sentry and Datadog
  • See design choices for more details


pip install spinach


from spinach import Engine, MemoryBroker

spin = Engine(MemoryBroker())

def compute(a, b):
    print('Computed {} + {} = {}'.format(a, b, a + b))

# Schedule a job to be executed ASAP
spin.schedule(compute, 5, 3)

print('Starting workers, ^C to quit')

The Engine is the central part of Spinach, it allows to define tasks, schedule jobs to execute in the background and start background workers. More details.

The Broker is the backend that background workers use to retrieve jobs to execute. Spinach provides two brokers: MemoryBroker for development and RedisBroker for production.

The Engine.task() decorator is used to register tasks. It requires at least a name to identify the task, but other options can be given to customize how the task behaves. More details.

Background jobs can then be scheduled by using either the task name or the task function:

spin.schedule('compute', 5, 3)  # identify a task by its name
spin.schedule(compute, 5, 3)    # identify a task by its function

Getting started with spinach:

Hacking guide: