Hi,
While analyzing the codebase with python-vibe-guard, I found a potential
issue in backend/services/messaging/message_service.py around line 241.
The function _push_messages is an async def that uses time.sleep(0.5)
as a throttle every 10 messages:
if (i + 1) % 10 == 0:
time.sleep(0.5)
time.sleep() blocks the entire event loop for 500ms — not just the current
coroutine. If this worker also handles other concurrent tasks (HTTP requests,
other async operations), every batch of 10 notifications introduces a 500ms
pause across all concurrent traffic on that worker.
Suggested fix (one-line change):
if (i + 1) % 10 == 0:
await asyncio.sleep(0.5)
This preserves the throttling behavior while allowing other coroutines to
run during the wait.
Tool used: python-vibe-guard —
AST-based runtime anti-pattern scanner validated on 902 real repositories.
Hi,
While analyzing the codebase with python-vibe-guard, I found a potential
issue in
backend/services/messaging/message_service.pyaround line 241.The function
_push_messagesis anasync defthat usestime.sleep(0.5)as a throttle every 10 messages:
time.sleep()blocks the entire event loop for 500ms — not just the currentcoroutine. If this worker also handles other concurrent tasks (HTTP requests,
other async operations), every batch of 10 notifications introduces a 500ms
pause across all concurrent traffic on that worker.
Suggested fix (one-line change):
This preserves the throttling behavior while allowing other coroutines to
run during the wait.
Tool used: python-vibe-guard —
AST-based runtime anti-pattern scanner validated on 902 real repositories.