Skip to main content

AppHandle

Protocol defining the common interface between local and remote app handles. Both _LocalApp (local serving) and App (remote serving) satisfy this protocol, enabling calling code to work uniformly regardless of the serving mode.

Attributes

AttributeTypeDescription
namestrThis attribute stores the name of the application handle, used to identify the application.
urlstrThis attribute stores the URL where the application is accessible, used for direct access to the application.
endpointstrThis attribute stores the specific API endpoint for the application, used for programmatic interaction with the application.

Methods


name()

@classmethod
def name() - > str

Retrieves the name of the application handle.

Returns

TypeDescription
strThe string name of the application.

url()

@classmethod
def url() - > str

Retrieves the URL where the application is accessible.

Returns

TypeDescription
strThe string URL of the application.

endpoint()

@classmethod
def endpoint() - > str

Retrieves the endpoint identifier for the application.

Returns

TypeDescription
strThe string endpoint identifier.

is_active()

@classmethod
def is_active() - > bool

Checks if the application handle is currently active.

Returns

TypeDescription
boolTrue if the application is active, False otherwise.

is_deactivated()

@classmethod
def is_deactivated() - > bool

Checks if the application handle is currently deactivated.

Returns

TypeDescription
boolTrue if the application is deactivated, False otherwise.

activate()

@classmethod
def activate(
wait: bool = False
) - > [AppHandle](apphandle.md?sid=flyte__serve_apphandle)

Activates the application handle, making it ready for use. Callers use this to start the application.

Parameters

NameTypeDescription
waitbool = FalseA boolean indicating whether to wait for the activation process to complete before returning.

Returns

TypeDescription
[AppHandle](apphandle.md?sid=flyte__serve_apphandle)The activated AppHandle instance.

deactivate()

@classmethod
def deactivate(
wait: bool = False
) - > [AppHandle](apphandle.md?sid=flyte__serve_apphandle)

Deactivates the application handle, stopping its operation. Callers use this to shut down the application.

Parameters

NameTypeDescription
waitbool = FalseA boolean indicating whether to wait for the deactivation process to complete before returning.

Returns

TypeDescription
[AppHandle](apphandle.md?sid=flyte__serve_apphandle)The deactivated AppHandle instance.

ephemeral_ctx()

@classmethod
def ephemeral_ctx() - > AbstractAsyncContextManager[None]

Provides an asynchronous context manager for ephemeral application states. Callers use this for temporary application configurations that are automatically cleaned up.

Returns

TypeDescription
AbstractAsyncContextManager[None]An asynchronous context manager that manages an ephemeral state.

ephemeral_ctx_sync()

@classmethod
def ephemeral_ctx_sync() - > AbstractContextManager[None]

Provides a synchronous context manager for ephemeral application states. Callers use this for temporary application configurations that are automatically cleaned up in a synchronous context.

Returns

TypeDescription
AbstractContextManager[None]A synchronous context manager that manages an ephemeral state.