Review the prerequisites
Suitable for: Backend developers learning Agent applications.
- Delivery conditions and shared deadlines for parallel results
- Parallelism only shortens independent waiting and does not change task dependencies and success conditions. Global deadlines constrain all attempts and backoffs; the cancellation of a local task does not prove that the remote side effects have stopped, and the results must be retained and classified item by item.
How does the mechanism work?
Step-by-step explanation
- What's the problem with calling the synchronous HTTP library in the async function?
Concurrent execution requires yielding control; function syntax alone does not guarantee this.
- Are other tasks still running after aggregation wait encounters an exception?
Error handling changes the lifecycle of concurrent tasks, so check the library's actual semantics.
- Why does the tool retry reusing the remaining time?
Local retries must obey the global delivery budget.
Foundation · Understand the concepts
Understand the principle · Delivery conditions and shared deadlines for parallel results
Objectives of this level: Parallelism only shortens independent waiting and does not change task dependencies and success conditions. Global deadlines constrain all attempts and backoffs; the cancellation of a local task does not prove that the remote side effects have stopped, and the results must be retained and classified item by item.
Visual guide · One deadline governs every branch
Required failures block; optional failures may yield partial. Cleanup must run on exceptions too, and local cancellation proves no remote noncommit. Select the figure to open it at full size.
Define delivery before adding concurrency
Three independent tools share absolute deadline 5. a is required; b/c are optional. This exercise uses integer logical time: advance(5) processes fixture completions at or before 5, and None means no completion in this run. Units are not milliseconds; no HTTP speed, scheduling latency, or production p95 is measured.
jobs = [
{"id": "a", "required": True, "complete_at": 1, "outcome": "ok", "value": "evidence-A", "effect_at": None},
{"id": "b", "required": False, "complete_at": 2, "outcome": "error", "value": None, "effect_at": None},
{"id": "c", "required": False, "complete_at": None, "outcome": "ok", "value": "never", "effect_at": None},
]
now = 0
deadline = 5
Item states are succeeded/failed/timeout. The batch is succeeded when every item succeeds; partial when all required items succeed but some optional item does not; blocked when any required item does not succeed. Partial preserves evidence; the business contract must decide whether it is deliverable. This lab tests that explicit aggregation contract.
Predict the original result first. Then separately change b and c to required=True and explain why successful a cannot replace a required check. Change a.complete_at to 5 and 6 to examine the boundary.
Guided run and your own work
The runtime needs only Python 3.9+ and the standard library. The guided run has two fixed jobs: successful a and hanging required c. Expect reported=blocked, four true checks, now=5, open_handles=[], exit 0. Its output demonstrates the runtime; your submitted module needs its own execution evidence.
mkdir -p deadline-practice
cd deadline-practice
curl --fail --location https://ai.lwkjob.com/lab/interview-practice/deadline_lab.py --output deadline_lab.py
python3 deadline_lab.py guided --out deadline-guided.json
For a real asyncio adapter, read the library lifecycle semantics. In Python 3.12, gather with default arguments propagates the first exception while other tasks continue. TaskGroup, added in 3.11, manages the group and cancels/waits for remaining tasks on an ordinary failure. Use try/finally for cleanup. A blocking request in a thread requires separate reasoning about what local cancellation actually stops.Python 3.12 asyncio semantics; lab source.
code example
Required-gate counterfactual
Requiring c blocks delivery despite successful a. Predict it first, then verify your own module.
Acceptance task for this level
Predict the fixed a/b/c input, then separately require b/c and change a completion to 5/6; submit item states, batch status, and reasons, labeling guided evidence separately.
Reading this browser’s record…
Hide the answer and check your understanding
a succeeds but required c never responds. Why is succeeded invalid?
Expand reference derivation
Every required item must succeed. A timeout for c blocks the batch while a is retained. Concurrency does not change business success criteria.
Further explanations and practice
When encountering unfamiliar principles, first read the implementation, continuous questioning and migration cases, and then independently explain the premise and boundaries. Answers and notes are saved to the original account record.
All linked explanations and exercises (1 )
Sources and verification scope
The principles are based on public information; the numbers, cases and tasks are the teaching design of this website. Offline experiments verify the range noted on this page, and the learning effect still needs to be judged through independent tasks and feedback.