Get state

This method returns the result state of a calculation. When a calculation is started, it is scheduled in a calculation queue first. The calculation directly returns a result state with a unique ID (field @id) of the result. Only when the state of a result is ready, calculation results can be retrieved.

APIMethod
RESTGET result/{result-id}/state
IPCresult/state
Python IPCResult.get_state
Return typeResultState

Examples

Python IPC

state = result.get_state()
if state.error:
    print(f"calculation failed: {state.error}")
    exit(-1)

# actively waiting for a result
import time

while not result.get_state().is_ready:
    time.sleep(1)
    print("waiting ...")

# or better do this:
state = result.wait_until_ready()
print(f"result id: {state.id}")

JSON-RPC via Fetch API

The example below shows the usage of this method using the JSON-RPC protocol via the Fetch API which is available in modern web-browsers or platforms like Deno.

  let resp = await fetch("http://localhost:8080", {
    method: "POST",
    body: JSON.stringify({
      jsonrpc: "2.0",
      id: 1,
      method: "result/state",
      params: {
        "@id": "e316a369-bf5b-4c25-a61f-3492cfca9535",
      }
    })
  });
  let v = await resp.json();
  console.log(v);
  // {
  //   jsonrpc: "2.0",
  //   result: {
  //     "@id": "e316a369-bf5b-4c25-a61f-3492cfca9535",
  //     isReady: true,
  //     isScheduled: false,
  //     time: 1671187586993
  //   },
  //   id: 1
  // }