Skip to content

Configuring Horsies

  • PostgreSQL 12+
  • Python 3.13+
Terminal window
uv add horsies
from horsies import Horsies, AppConfig, PostgresConfig
config = AppConfig(
broker=PostgresConfig(
database_url="postgresql+psycopg://user:password@localhost:5432/mydb",
),
)
app = Horsies(config)

Different operations have different urgency levels can be defined with priority values. 1-100 where 1 is priority numero uno.

from horsies import Horsies, AppConfig, PostgresConfig, QueueMode, CustomQueueConfig
config = AppConfig(
queue_mode=QueueMode.CUSTOM,
custom_queues=[
CustomQueueConfig(name="urgent", priority=1, max_concurrency=10),
CustomQueueConfig(name="standard", priority=50, max_concurrency=20),
CustomQueueConfig(name="low", priority=100, max_concurrency=5),
],
broker=PostgresConfig(
database_url="postgresql+psycopg://user:password@localhost:5432/db_name",
),
)
app = Horsies(config) # use this app instance for decorating task
QueuePriorityUse Case
urgent1The most important queue
standard50Things in between
low100The least important, can wait
app.discover_tasks([
"myapp.tasks",
"myapp.workflows",
])

discover_tasks records module paths for later import by the worker. Dotted module paths use importlib.import_module(), while .py entries are imported by file path — it does not recursively scan submodules.

To discover tasks in myapp.tasks.scraping, either list it explicitly:

app.discover_tasks([
"myapp.tasks",
"myapp.tasks.scraping",
"myapp.workflows",
])

Or export the decorated functions from myapp.tasks.__init__.py so importing myapp.tasks triggers the decorator registration.

Terminal window
horsies worker myapp.config:app --processes=8 --loglevel=INFO