AI Engineer Portal
Your personal operating system for career transition.
Private mode
Exercise
Build a request queue with priority routing
Implement an in-memory PriorityInferenceQueue that:
- Accepts inference requests with a
priorityfield:"high","normal", or"low" - Always dequeues high-priority requests before normal, and normal before low
- Returns
Nonefromdequeue()if the queue is empty - Exposes a
depth()method returning a dict with counts per priority level and atotalkey - Is safe for use with
asyncio(useasyncio.Queueor equivalent, not threading primitives)
import asyncio
from dataclasses import dataclass
@dataclass
class InferenceRequest:
request_id: str
messages: list[dict]
priority: str # "high", "normal", "low"
class PriorityInferenceQueue:
def __init__(self):
# TODO: initialize separate queues per priority level
pass
async def enqueue(self, request: InferenceRequest) -> None:
# TODO: add to the correct priority queue
raise NotImplementedError
async def dequeue(self) -> InferenceRequest | None:
# TODO: return highest-priority item, or None if empty
raise NotImplementedError
def depth(self) -> dict:
# TODO: return {"high": n, "normal": n, "low": n, "total": n}
raise NotImplementedError
Deployment / medium / Step 2 of 6
Practice stage
General drill
Hint
Keep the solution explicit and reviewable.
Success criteria
Make the solution explicit, debuggable, and easy to explain.
Review checklist
Review where the boundary is, what gets validated, and what would be hard to debug later.
Practice
Generate a variation
Generate a new exercise variation to deepen understanding or practice a related concept.
Attempt history
Recent submissions
Before you submit, decide what a strong answer should make obvious to the reviewer.
No attempts yet.