WattsonResponsePromise#

class wattson.cosimulation.control.messages.wattson_response_promise.WattsonResponsePromise(query: WattsonQuery, resolve_event: Event)#

Bases: WattsonResponse

Methods

__init__

get_response

If the associated query has been resolved, the respective WattsonResponse is returned.

is_promise

is_resolved

Checks whether the associated query has already been resolved

on_resolve

Adds a callback to be called as soon as the promise resolves.

raise_exception_on_fail

As soon as the response resolves, it is checked for its success.

resolve

Wait for the query to resolve.

trigger_resolve

Attributes

query

resolve_event

__init__(query: WattsonQuery, resolve_event: Event)#
get_response() WattsonResponse | None#

If the associated query has been resolved, the respective WattsonResponse is returned. Otherwise, None is returned.

is_resolved() bool#

Checks whether the associated query has already been resolved

on_resolve(callback: Callable[[WattsonResponse], None])#

Adds a callback to be called as soon as the promise resolves.

Parameters:

callback (Callable[[WattsonResponse], None]) – The callback to call

raise_exception_on_fail()#

As soon as the response resolves, it is checked for its success. In case it is not successful, an exception is raised.

resolve(timeout: float | None = None) bool#

Wait for the query to resolve. If a timeout is given, the waiting is stopped after this timeout (in seconds). Returns True iff the query has been resolved.

Parameters:

timeout (Optional[float], optional) – (Default value = None)