Labs / Chapter 4
Checkout returns while the fraud call is still running
Start with a provider call that fits inside the child deadline. Then slow the provider until work is still running after checkout returns. Pass cancellation with the deadline, then refuse the permit once and compare the deferred path.
The system
The child deadline is 750 ms, capped at 1000 ms. Checkout returns at 80 ms and the provider is not still running.
reserve_fraud_call
- # remaining_ms = provider_ms =
- def reserve_fraud_call(request):
- deadline = request.child_deadline(
- maximum_ms=1000,
- reserve_ms=,
- )
- if not deadline.can_start_call():
- return deadline, None
- permit =
- def evaluate_risk(assessment, request, permit, deadline):
- with permit:
- cancellation=
- Child deadline750 ms, capped at 1000
- Caller80 ms of 800 left
- Provider80 ms, inside the child deadline
Caller time and provider work left running
Caller time should stay inside the time checkout has left. The second line is provider work continuing after checkout returns.
Caller 80.0 · Still running 0.0
The chart fills as the lab runs. ms is the vertical unit.
- Caller
- Still running
- ms
