use of org.apache.zeppelin.interpreter.jupyter.proto.ExecuteResponse in project zeppelin by apache.
the class JupyterKernelClient method block_execute.
// blocking execute the code
public ExecuteResponse block_execute(ExecuteRequest request) {
ExecuteResponse.Builder responseBuilder = ExecuteResponse.newBuilder();
responseBuilder.setStatus(ExecuteStatus.SUCCESS);
Iterator<ExecuteResponse> iter = blockingStub.execute(request);
StringBuilder outputBuilder = new StringBuilder();
try {
// iter.hasNext may throw exception, so use try catch outside.
while (iter.hasNext()) {
ExecuteResponse nextResponse = iter.next();
if (nextResponse.getStatus() == ExecuteStatus.ERROR) {
responseBuilder.setStatus(ExecuteStatus.ERROR);
}
outputBuilder.append(nextResponse.getOutput());
}
responseBuilder.setOutput(outputBuilder.toString());
} catch (Exception e) {
responseBuilder.setStatus(ExecuteStatus.ERROR);
responseBuilder.setOutput(outputBuilder.toString());
}
return responseBuilder.build();
}
Aggregations