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.
| Method | Parameters | Returns |
|---|---|---|
state | ResultState |
In Python, the method is Result.get_state. There is also the method
Result.wait_until_ready which polls the state until the result is ready.
Try it
You can edit and execute the example below. Just make sure an openLCA IPC
server is running on port 8080:
const v = await call("result/state", {
"@id": "e316a369-bf5b-4c25-a61f-3492cfca9535",
});
console.log(v);
// {
// "@id": "e316a369-bf5b-4c25-a61f-3492cfca9535",
// isReady: true,
// isScheduled: false,
// time: 1671187586993
// }
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}")