def _submit_and_await_termination( client: skein.Client, spec: skein.ApplicationSpec, tasks: typing.List[str], poll_every_secs: int = 10 ): app = client.submit_and_connect(spec) events: typing.Dict[str, typing.Dict[str, str]] = {task: {} for task in tasks} event_listener = Thread(target=_aggregate_events, args=(app.kv, events)) event_listener.start() with _shutdown_on_exception(app): state = None while True: report = client.application_report(app.id) logger.info( f"Application report for {app.id} (state: {report.state})") if state != report.state: logger.info(_format_app_report(report)) if report.final_status != "undefined": event_listener.join() logger.info(_format_run_summary(events)) if report.final_status == "failed": raise RunFailed else: break time.sleep(poll_every_secs) state = report.state
def wait_for_finished(client: skein.Client, app_id: str): logger.info(f"application_id: {app_id}") while True: report = client.application_report(app_id) logger.info(report) if report.final_status != "undefined": logger.info(report.final_status) break time.sleep(3)