Search in sources :

Example 6 with NamespaceClient

use of com.twosigma.beakerx.NamespaceClient in project beakerx by twosigma.

the class GroovyWorkerThread method call.

@Override
public TryResult call() throws Exception {
    NamespaceClient nc = null;
    TryResult r;
    try {
        if (!GroovyEvaluator.LOCAL_DEV) {
            nc = NamespaceClient.getBeaker(groovyEvaluator.getSessionId());
            nc.setOutputObj(j.outputObject);
        }
        j.outputObject.started();
        String code = j.codeToBeExecuted;
        r = groovyEvaluator.executeTask(new GroovyCodeRunner(groovyEvaluator, code, j.outputObject));
        if (nc != null) {
            nc.setOutputObj(null);
            nc = null;
        }
    } catch (Throwable e) {
        if (e instanceof GroovyNotFoundException) {
            logger.warn(e.getLocalizedMessage());
            r = TryResult.createError(e.getLocalizedMessage());
        } else {
            e.printStackTrace();
            r = TryResult.createError(e.getLocalizedMessage());
        }
    } finally {
        if (nc != null) {
            nc.setOutputObj(null);
            nc = null;
        }
    }
    return r;
}
Also used : NamespaceClient(com.twosigma.beakerx.NamespaceClient) TryResult(com.twosigma.beakerx.TryResult)

Aggregations

NamespaceClient (com.twosigma.beakerx.NamespaceClient)6 TryResult (com.twosigma.beakerx.TryResult)5 IOException (java.io.IOException)2 BeakerParser (com.twosigma.beakerx.sql.BeakerParser)1 DBConnectionException (com.twosigma.beakerx.sql.DBConnectionException)1 DataSource (javax.sql.DataSource)1