caikit.runtime.http_server.request_aborter

This module helps us know when a HTTP client call is cancelled, and we need to stop or undo work

Attributes

log

Classes

HttpRequestAborter

In order to actually interrupt threads doing the work, abortable contexts can be registered

Module Contents

caikit.runtime.http_server.request_aborter.log[source]
class caikit.runtime.http_server.request_aborter.HttpRequestAborter(context: fastapi.Request, loop: asyncio.AbstractEventLoop | None = None, poll_time: float | None = 0.25)[source]

Bases: caikit.runtime.work_management.abortable_context.ActionAborter

In order to actually interrupt threads doing the work, abortable contexts can be registered with an instance of this class in order to receive notification on request disconnection. This allows work to be terminated when a client time’s out or stops listening.

IFF the client request has been terminated, must_abort will return True.

context
event_loop
poll_time = 0.25
is_terminated
abortable_context = None
task
__enter__()[source]

Helper function to enable context manager support

__exit__(exc_type, exc_val, exc_tb)[source]

Automatically abort aborter when exiting contextmanager

async watch_for_disconnect()[source]

Wait for a context to be disconnected

abort()[source]

Helper function to stop aborter before the request has terminated

must_abort()[source]

Indicate whether or not the action must be aborted

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