caikit.runtime.work_management.rpc_aborter
This module helps us know when an rpc call is cancelled, and we need to stop or undo work
Attributes
Classes
This class registers a callback with a grpc context, to be called in the event of rpc |
Module Contents
- class caikit.runtime.work_management.rpc_aborter.RpcAborter(context: grpc.ServicerContext)[source]
Bases:
caikit.runtime.work_management.abortable_context.ActionAborterThis class registers a callback with a grpc context, to be called in the event of rpc termination. Termination could be nominal (we returned a response) but we should have relinquished control anyway. The interesting case is when a client cancels a call or a deadline is hit, which could trigger this callback but will not interrupt the thread doing work.
In order to actually interrupt threads doing the work, abortable contexts can be registered with an instance of this class in order ton receive notification on RPC termination.
IFF the RPC has been terminated, must_abort will return True.
- is_terminated = False
- context = None
- set_context(context: caikit.runtime.work_management.abortable_context.AbortableContext)[source]
Set the abortable context that must be notified to abort work
- unset_context()[source]
Unset any abortable context already held. Do not notify it that work should abort
- __rpc_terminated()