caikit.core.toolkit.concurrency.destroyable_process
A DestroyableProcess implements a multiprocessing Process that captures errors and communicates them to its parent with clean semantics for being destroyed.
- NOTE: The “fork” start method is used for two reasons:
It’s faster
- For auto-generated classes (e.g. stream sources), “spawn” can result in
missing classes since it performs a full re-import, but may not regenerate these classes.
Attributes
Classes
The _DestroyableProcess base class implements a context-agnostic process |
|
Process objects represent activity that is run in a separate process |
|
Process objects represent activity that is run in a separate process |
|
Process objects represent activity that is run in a separate process |
Functions
|
Class wrapper that returns the appropriate process type based on the |
Module Contents
- caikit.core.toolkit.concurrency.destroyable_process.error
- caikit.core.toolkit.concurrency.destroyable_process.OOM_EXIT_CODES
- caikit.core.toolkit.concurrency.destroyable_process.FORK_CTX = None
- caikit.core.toolkit.concurrency.destroyable_process.SPAWN_CTX = None
- caikit.core.toolkit.concurrency.destroyable_process.FORKSERVER_CTX = None
- class caikit.core.toolkit.concurrency.destroyable_process._DestroyableProcess(target: Callable | None = None, completion_event: multiprocessing.Event | None = None, args: Tuple | None = None, kwargs: dict | None = None, destroy_grace_period: float = 10, return_result: bool = False, **_kwargs)[source]
Bases:
multiprocessing.process.BaseProcess,caikit.core.toolkit.concurrency.destroyable.DestroyableThe _DestroyableProcess base class implements a context-agnostic process class that manages the subprocess and allows it to be destroyed
- _completion_event
- _destroy_grace_period = 10
- _return_result = False
- __result = None
- __started = False
- __destroyed = False
- __canceled = False
- property destroyed: bool
Return True if destroy was called, regardless of whether the destroyable was alive at the time
- property canceled: bool
Returns True if destroyed while actively working
- property ran: bool
Return True if the destroyable completed execution in any state
- property threw: bool
Return True if any exception was raised during execution
- property error: Exception | None
Return the error information to user if one occurred
- property completion_event: multiprocessing.Event
- caikit.core.toolkit.concurrency.destroyable_process._PROCESS_TYPES
- class caikit.core.toolkit.concurrency.destroyable_process._ForkDestroyableProcess(group=None, target=None, name=None, args=(), kwargs={}, *, daemon=None)[source]
Bases:
FORK_CTX,_DestroyableProcessProcess objects represent activity that is run in a separate process
The class is analogous to threading.Thread
- _MP_CTX
- class caikit.core.toolkit.concurrency.destroyable_process._SpawnDestroyableProcess(group=None, target=None, name=None, args=(), kwargs={}, *, daemon=None)[source]
Bases:
SPAWN_CTX,_DestroyableProcessProcess objects represent activity that is run in a separate process
The class is analogous to threading.Thread
- _MP_CTX
- class caikit.core.toolkit.concurrency.destroyable_process._ForkserverDestroyableProcess(group=None, target=None, name=None, args=(), kwargs={}, *, daemon=None)[source]
Bases:
FORKSERVER_CTX,_DestroyableProcessProcess objects represent activity that is run in a separate process
The class is analogous to threading.Thread
- _MP_CTX