try single threaded

This commit is contained in:
marc hurabielle 2019-03-22 18:30:25 +09:00
parent f14d8b2425
commit 6e48c13805

View file

@ -301,31 +301,33 @@ public class IPythonInterpreterTest extends BasePythonInterpreterTest {
// 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);
}
});
// 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);
// pool.execute(interpretFuture);
// we sleep to ensure that the paragraph is running
Thread.sleep(3000);
pool.execute(completionFuture);
// Thread.sleep(3000);
// pool.execute(completionFuture);
// We ensure that running and auto completion are not hanging.
InterpreterResult res = interpretFuture.get(20000, TimeUnit.MILLISECONDS);
List<InterpreterCompletion> autoRes = completionFuture.get(1000, TimeUnit.MILLISECONDS);
assertTrue(res.code().name().equals("SUCCESS"));
// InterpreterResult res = interpretFuture.get(20000, TimeUnit.MILLISECONDS);
// List<InterpreterCompletion> autoRes = completionFuture.get(1000, TimeUnit.MILLISECONDS);
InterpreterResult res = interpreter.interpret(code, getInterpreterContext());
List<InterpreterCompletion> autoRes = interpreter.completion(base, base.length(), null);
assertTrue(res.code().name().equals("SUCCESS"));
assertTrue(autoRes.size() > 0);
}