Loading...
Loading...
Browse 7 real-world technical and behavioral interview questions about Cancellation. Review scenarios, edge cases, and architectural best practices.
A timeout requests cancellation; it does not stop code. CancelledError is raised at the task next await point, so a task inside blocking code, shielded, in an executor thread, or swallowing the exception keeps running and commits its side effects late. Fix by re-raising CancelledError, keeping blocking calls off the loop, and using asyncio.timeout with a TaskGroup.
They are almost certainly on risk, because the contract was formed when you accepted the risk and not when the money cleared. The remedy is cancellation for non-payment, which runs forwards from a notice date rather than erasing the policy, so the system needs a pending-cancellation state and an answer for a claim inside the unpaid window.
A CancellationToken in C# is cooperative cancellation, not a thread abort. Pass it through async calls, check it around long CPU loops, and define whether cancelled work leaves durable side effects behind.
It depends on who cancelled and why: pro rata returns the unused share, short rate keeps a penalty, and which applies is set by the policy wording and the jurisdiction rather than by the system. Fees are usually not refundable, and the calculation has to be reproducible years later.
Go context cancellation stops wasted request work when the client disconnects or a timeout expires. Pass the request context into database, HTTP and worker calls, and make goroutines return when ctx.Done closes.
With gather they keep running unsupervised and their failures may surface as an unretrieved-exception warning. A TaskGroup, added in Python 3.11, cancels the siblings, waits for them to finish unwinding, and raises an ExceptionGroup you handle with except*.
Streaming commits you to the response before you have seen it: the status code is already sent, any check that needs the whole output now runs after the user has read part of it, a mid-stream failure has no clean retry, and an abandoned tab keeps generating tokens you pay for. It also connects llm serving to the point an interviewer is testing.