fix rebase

This commit is contained in:
marc hurabielle 2019-09-07 15:22:32 +09:00
parent 5bed19496d
commit 86dab7345b

View file

@ -412,46 +412,5 @@ public class IPythonInterpreterTest extends BasePythonInterpreterTest {
assertTrue(exceptionMsg, exceptionMsg.contains("No such file or directory"));
}
}
@Test
public void testIpython_shouldNotHang_whenCallingAutoCompleteAndInterpretConcurrently()
throws InterpreterException,
InterruptedException, TimeoutException, ExecutionException {
Properties properties = initIntpProperties();
startInterpreter(properties);
final String code = "import time\n"
+ "print(1)\n"
+ "time.sleep(5)\n"
+ "print(2)";
final String base = "time.";
// The goal of this test is to ensure that concurrent interpret and complete
// will not make execute hang forever.
ExecutorService pool = Executors.newFixedThreadPool(2);
FutureTask<InterpreterResult> interpretFuture =
new FutureTask(new Callable() {
@Override
public Object call() throws Exception {
return interpreter.interpret(code, getInterpreterContext());
}
});
FutureTask<List<InterpreterCompletion>> completionFuture =
new FutureTask(new Callable() {
@Override
public Object call() throws Exception {
return interpreter.completion(base, base.length(), null);
}
});
pool.execute(interpretFuture);
// we sleep to ensure that the paragraph is running
Thread.sleep(2000);
pool.execute(completionFuture);
// We ensure that running and auto completion are not hanging.
InterpreterResult res = interpretFuture.get(15000, TimeUnit.MILLISECONDS);
List<InterpreterCompletion> autoRes = completionFuture.get(1000, TimeUnit.MILLISECONDS);
assertTrue(res.code().name().equals("SUCCESS"));
assertTrue(autoRes.size() > 0);
}
}