WattsonAsyncGroupResponse#

class wattson.cosimulation.control.messages.wattson_async_group_response.WattsonAsyncGroupResponse(group_key: Any)#

Bases: WattsonAsyncResponse

The WattsonAsyncGroupResponse is a WattsonAsyncResponse that can send identical data to multiple clients. This is used for static queries that contain a larger data model. In this case, a single notification is sent to indicate the resolved queries instead of several individual notifications.

Methods

__init__

block

Blocks this response from being resolved.

copy_for_sending

When sending the object, instances of complex classes (e.g., the WattsonServer or a threading.Event) are removed.

get_reference

get_reference_map

has_response

is_promise

is_resolvable

is_successful

register_reference

Warning: This is only safe to call if you have blocked the response previously!

resolve

resolve_with_task

Calls the given function (resolve_task) in a new thread to allow for asynchronous resolution.

set_successful

unblock

Remove the blocking of this response.

__init__(group_key: Any)#
block(timeout: float = 1) bool#

Blocks this response from being resolved.

Returns:

True if the response could be blocked, False otherwise.

Return type:

bool

copy_for_sending(client_id: str | None = None) WattsonAsyncResponse#

When sending the object, instances of complex classes (e.g., the WattsonServer or a threading.Event) are removed.

register_reference(client_id: str, reference_id: int) bool#

Warning: This is only safe to call if you have blocked the response previously!

Parameters:
  • client_id – The client ID of the client that should receive the response.

  • reference_id – The reference ID of the response, linking to the query.

Returns:

True if the response could be registered, False otherwise.

resolve_with_task(resolve_task: Callable[[WattsonAsyncResponse, Dict], WattsonResponse], further_kwargs: Dict | None = None)#

Calls the given function (resolve_task) in a new thread to allow for asynchronous resolution. After the resolve_task finishes and returns a WattsonResponse, this WattsonAsyncResponse is automatically resolved.

Parameters:
  • resolve_task (Callable[['WattsonAsyncResponse', Dict], WattsonResponse]) – The callable to call for deriving the full WattsonResponse

  • further_kwargs (Optional[Dict], optional) – A dict with further arguments to pass to the resolve_task function (as a dict!). If None is given, an empty dict is created. (Default value = None)

unblock()#

Remove the blocking of this response.