Commit bb7e46f0 authored by Daniele Venzano's avatar Daniele Venzano

Manage exceptions when starting a ZApp in idle script

parent 49d10e77
...@@ -16,6 +16,7 @@ import os ...@@ -16,6 +16,7 @@ import os
from zoe_cmd.utils import read_auth from zoe_cmd.utils import read_auth
from zoe_cmd.api_lib import ZoeAPI from zoe_cmd.api_lib import ZoeAPI
import zoe_lib.exceptions
TOTAL_JOBS = 1000 TOTAL_JOBS = 1000
USAGE_WATERMARK = 0.4 USAGE_WATERMARK = 0.4
...@@ -54,7 +55,12 @@ def load_zapp(filename): ...@@ -54,7 +55,12 @@ def load_zapp(filename):
def submit_zapp(zapps, name, api): def submit_zapp(zapps, name, api):
"""Submits one ZApp for execution.""" """Submits one ZApp for execution."""
zapp = random.choice(zapps) zapp = random.choice(zapps)
ret = api.executions.start(name, zapp) try:
ret = api.executions.start(name, zapp)
except zoe_lib.exceptions.ZoeAPIException as e:
print('Error starting ZApp: {}'.format(str(e)))
ret = None
return ret return ret
...@@ -113,7 +119,8 @@ def keep_some_running(zapps, exec_name, api): ...@@ -113,7 +119,8 @@ def keep_some_running(zapps, exec_name, api):
while usage <= USAGE_WATERMARK: while usage <= USAGE_WATERMARK:
print("Platform usage is {:.2f}, can start one more".format(usage)) print("Platform usage is {:.2f}, can start one more".format(usage))
zapp_id = submit_zapp(zapps, exec_name, api) zapp_id = submit_zapp(zapps, exec_name, api)
print("ZApp submitted with ID {}".format(zapp_id)) if zapp_id is not None:
print("ZApp submitted with ID {}".format(zapp_id))
time.sleep(5) time.sleep(5)
queue_length = check_queue_length(api) queue_length = check_queue_length(api)
if queue_length > 0: if queue_length > 0:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment