Repid
Repid is a simple, fast, and extensible async task queue framework, with built-in AsyncAPI 3.0 schema generation.
Example
Here is how the easiest example of producer-consumer application can look like.
import asyncio
from repid import Repid, Router, InMemoryServer
# 1. Initialize the application and register a server
app = Repid()
app.servers.register_server("default", InMemoryServer(), is_default=True)
# 2. Create a router and an actor
router = Router()
@router.actor(channel="tasks")
async def my_awesome_actor(user_id: int) -> None:
print(f"Processing for {user_id}")
await asyncio.sleep(1.0)
app.include_router(router)
async def main() -> None:
# 3. Open connection to interact with the queue
async with app.servers.default.connection():
# Producer: Send a message
await app.send_message_json(
channel="tasks",
payload={"user_id": 123},
headers={"topic": "my_awesome_actor"}
)
# Consumer: Run the worker loop (in a real app, this would be a separate process)
await app.run_worker(messages_limit=1)
if __name__ == "__main__":
asyncio.run(main())
Install
Repid supports Python versions 3.10 and up and is installable via pip.
There are also a couple of additional dependencies you may want to install, depending on your use case:
Why Repid?
Repid brings modern Python developer experience (DX) to background tasks, moving away from legacy patterns and embracing strong typing, clear architecture, and flexibility.
- 📖 AsyncAPI Native: Stop maintaining outdated architecture diagrams. Repid automatically inspects your actors and generates AsyncAPI 3.0 schemas and interactive web documentation.
- 🛡️ Modern Typing & Validation: First-class Pydantic support. Your message payloads and headers are strictly validated and type-coerced before your actors even run.
- 💉 Dependency Injection: Write clean, testable code. Inject database connections, settings, or shared logic directly into your actor signatures.
- 🔌 Highly Unopinionated: Repid doesn't force a strict ecosystem. You can use it as just a producer, just a consumer, or easily swap out underlying message brokers without rewriting your business logic.
LLMs
Repid documentation is available in text formats optimized for Large Language Models (LLMs) and AI coding assistants:
- llms.txt - A concise overview and guide.
- llms-full.txt - The complete documentation in a single file.
Inspiration
Repid is inspired by FastAPI,
dramatiq and arq.
License
Repid is distributed under the terms of the MIT license. Please see License.md for more information.
Repid's logo is distributed under the terms of the CC BY-NC 4.0 license. It is originally created by ari_the_crow_.