caikit.runtime.http_server.request_aborter ========================================== .. py:module:: caikit.runtime.http_server.request_aborter .. autoapi-nested-parse:: This module helps us know when a HTTP client call is cancelled, and we need to stop or undo work Attributes ---------- .. autoapisummary:: caikit.runtime.http_server.request_aborter.log Classes ------- .. autoapisummary:: caikit.runtime.http_server.request_aborter.HttpRequestAborter Module Contents --------------- .. py:data:: log .. py:class:: HttpRequestAborter(context: fastapi.Request, loop: Optional[asyncio.AbstractEventLoop] = None, poll_time: Optional[float] = 0.25) Bases: :py:obj:`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. .. py:attribute:: context .. py:attribute:: event_loop .. py:attribute:: poll_time :value: 0.25 .. py:attribute:: is_terminated .. py:attribute:: abortable_context :value: None .. py:attribute:: task .. py:method:: __enter__() Helper function to enable context manager support .. py:method:: __exit__(exc_type, exc_val, exc_tb) Automatically abort aborter when exiting contextmanager .. py:method:: watch_for_disconnect() :async: Wait for a context to be disconnected .. py:method:: abort() Helper function to stop aborter before the request has terminated .. py:method:: must_abort() Indicate whether or not the action must be aborted .. py:method:: set_context(context: caikit.runtime.work_management.abortable_context.AbortableContext) Set the abortable context that must be notified to abort work .. py:method:: unset_context() Unset any abortable context already held. Do not notify it that work should abort