Async Programming Anti-patterns - Junior¶
asyncsyntax does not guarantee concurrency or non-blocking behavior.
This loop is async but sequential:
Each load starts only after the previous one finishes. Sequential execution may be correct, but adding async did not create overlap. This version is worse:
It is "fake async": the function monopolizes the event loop and gains nothing from the async calling convention.
flowchart LR
A[await partition 1] --> B[await partition 2] --> C[await partition 3]
D[async CPU transform] --> E[Blocks event-loop progress]
Use async for overlapping waits. Use ordinary synchronous code when simplicity wins, and parallel compute when CPU work is the bottleneck.
Test yourself¶
- Why is awaiting inside a loop often sequential?
- What makes a function "fake async"?
- Which model suits CPU-heavy row transformation?
Continue to middle.md.