Code RoomAudit events lost on shutdown
MediumPrep Room Coding #2205

Audit events lost on shutdown

Code reviewConcurrencyMid–Senior~27 min

Review this Python asyncio code that records audit events.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 27 min
Mark a line and say what kind of problem it is.0 findings
1import asyncio
2 
3async def write_audit(event):
4 await db.execute("INSERT INTO audit VALUES ($1)", event)
5 
6async def handle_request(req):
7 result = await process(req)
8 asyncio.create_task(write_audit(req.id)) # log in background
9 return result
10 
11async def main():
12 for req in incoming():
13 await handle_request(req)
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.