Is there a simple pattern to follow to cancel all work and all downstream gRPC requests when an incoming request to a synchronous Python gRPC server is cancelled?
I assumed this was handled, but this page suggests it is not: https://github.com/grpc/grpc/tree/master/examples/python/cancellation
It's important to remember that a gRPC Python server is backed by a thread pool with a fixed size. When an RPC is cancelled, the library does not terminate your servicer thread. It is your responsibility as the application author to ensure that your servicer thread terminates soon after the RPC has been cancelled.
There they handle it by passing down a threading.Event() which seems cumbersome for a deep call stack. Are there alternatives?