lacing.worker#
Optional Arq integration — queue processors through Redis.
This module imports arq only when needed, so it’s safe to import
even without [arq] installed. The actual WorkerSettings class is
constructed lazily by build_worker_settings().
Usage:
# In a worker process — assumes Redis is running.
import asyncio
from lacing.worker import build_worker_settings
from arq import run_worker
settings = build_worker_settings(
store_factory=lambda: SqliteStore("project.annot", check_same_thread=False),
oplog_factory=lambda: SqliteOpLog("project.annot.oplog", check_same_thread=False),
)
run_worker(settings)
# In your app — enqueue a processor:
from arq.connections import create_pool, RedisSettings
redis = await create_pool(RedisSettings())
await redis.enqueue_job(
"run_processor",
"low_confidence_review",
threshold=0.4,
)
For testing and small-scale work, prefer lacing.processors.run_sync()
— it runs the same registered processor in the current event loop with
no Redis needed.
Functions
|
Build an Arq |