bec_widgets.cli.rpc.rpc_base#

Attributes#

Exceptions#

DeletedWidgetError

Common base class for all non-exit exceptions.

RPCResponseTimeoutError

Exception raised when an RPC response is not received within the expected time.

Classes#

Functions#

_name_arg(arg)

_transform_args_kwargs(→ tuple[tuple, dict])

check_for_deleted_widget(func)

rpc_call(func)

A decorator for calling a function on the server.

rpc_timeout(timeout)

A decorator to set a timeout for an RPC call.

Module Contents#

exception DeletedWidgetError#

Bases: Exception

Common base class for all non-exit exceptions.

Initialize self. See help(type(self)) for accurate signature.

exception RPCResponseTimeoutError(request_id, timeout)#

Bases: Exception

Exception raised when an RPC response is not received within the expected time.

Initialize self. See help(type(self)) for accurate signature.

class RPCBase(gui_id: str | None = None, config: dict | None = None, object_name: str | None = None, parent=None, **kwargs)#
__repr__()#
_create_widget_from_msg_result(msg_result)#
_gui_is_alive()#

Check if the GUI is alive.

static _on_rpc_response(msg_obj: bec_lib.connector.MessageObject, parent: RPCBase) None#
_refresh_references()#

Refresh the references.

_run_rpc(method, *args, wait_for_rpc_response=True, timeout=5, gui_id: str | None = None, **kwargs) Any#

Run the RPC call.

Parameters:
  • method – The method to call.

  • args – The arguments to pass to the method.

  • wait_for_rpc_response – Whether to wait for the RPC response.

  • timeout – The timeout for the RPC response.

  • gui_id – The GUI ID to use for the RPC call. If None, the default GUI ID is used.

  • kwargs – The keyword arguments to pass to the method.

Returns:

The result of the RPC call.

raise_window()#

Bring this widget (or its container) to the front.

remove()#

Remove the widget.

property _root: bec_widgets.cli.client_utils.BECGuiClient#

Get the root widget. This is the BECFigure widget that holds the anchor gui_id.

object_name = None#
class RPCReference(registry: dict, gui_id: str)#
__dir__()#
__getattr__(name)#
__repr__()#
__setattr__(name, value)#
__str__()#
_is_deleted() bool#
object_name#
_name_arg(arg)#
_transform_args_kwargs(args, kwargs) tuple[tuple, dict]#
check_for_deleted_widget(func)#
rpc_call(func)#

A decorator for calling a function on the server.

Parameters:

func – The function to call.

Returns:

The result of the function call.

rpc_timeout(timeout)#

A decorator to set a timeout for an RPC call.

Parameters:

timeout – The timeout in seconds.

Returns:

The decorated function.

client#