1. Runs the request multiple times (up to 20 iterations), letting it progress further each time before cancelling — this exercises different cancellation points
2. Verifies the cancelled request produces a 499
3. Marks the logging context as finished to detect re-activation
4. Runs a final request to completion to verify no state was leaked from cancellations
It's not quite as thorough as the original (which intercepted every single Deferred.__await__ call), but it tests the same properties: clean cancellation at multiple points, proper 499 response, and no leaked state. The
limitation is that asyncio.Future.__await__ can't be patched from Python, so we can't intercept every individual await — instead we vary how many event loop ticks the request gets before cancellation.