caikit.runtime.work_management.abortable_context
Attributes
Classes
Simple interface to wrap up a notification that an action must abort. |
|
This class implements a listener which will observe all ongoing work in AbortableContexts |
|
Context manager for running work inside a context where it's safe to abort. |
Module Contents
- class caikit.runtime.work_management.abortable_context.ActionAborter[source]
Bases:
abc.ABCSimple interface to wrap up a notification that an action must abort.
Children of this class can bind to any notification tool (e.g. grpc context)
- abstract set_context(context: AbortableContext)[source]
Set the abortable context that must be notified to abort work
- class caikit.runtime.work_management.abortable_context.ThreadInterrupter[source]
This class implements a listener which will observe all ongoing work in AbortableContexts and raise exceptions in the working threads if they need to be aborted.
The implementation spawns a single extra thread to wait on any contexts to abort, and interrupt the thread that the context is running in. This keeps the total number of running threads much smaller than using a new thread to monitor each AbortableContext.
- _SHUTDOWN_SIGNAL = -1
- _queue
- _thread: threading.Thread | None = None
- _context_thread_map: Dict[uuid.UUID, int]
- _start_stop_lock
- class caikit.runtime.work_management.abortable_context.AbortableContext(aborter: ActionAborter, interrupter: ThreadInterrupter)[source]
Context manager for running work inside a context where it’s safe to abort.
This is a class instead of a @contextmanager function because __exit__ needs to happen on exception.
- aborter
- interrupter
- id