Skip to content

Commit

Permalink
Update task cancellation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmnbroad committed Aug 10, 2021
1 parent 5e1d98f commit a3b36b1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public Future<Integer> waitForPreviousBatchCompletion() {
*/
public boolean terminate() {
boolean isCancelled = true;
if (previousBatch != null) {
if (previousBatch != null && !previousBatch.isDone()) {
logger.warn("Cancelling outstanding asynchronous writing");
isCancelled = previousBatch.cancel(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,6 @@ public void testRaiseAsynchronousPythonException(final PythonScriptExecutor.Pyth
try {
streamingPythonExecutor.sendAsynchronousCommand("raise Exception" + NL);
streamingPythonExecutor.waitForAck();
} catch (PythonScriptExecutorException e) {
throw e;
} finally {
streamingPythonExecutor.terminate();
Assert.assertFalse(streamingPythonExecutor.getProcess().isAlive());
Expand All @@ -287,8 +285,6 @@ public void testRaiseAsynchronousBatchWritePythonException(final PythonScriptExe
BATCH_SIZE);
streamingPythonExecutor.startBatchWrite(batchCommand, batchList);
streamingPythonExecutor.waitForPreviousBatchCompletion();
} catch (PythonScriptExecutorException e) {
throw e;
} finally {
streamingPythonExecutor.terminate();
Assert.assertFalse(streamingPythonExecutor.getProcess().isAlive());
Expand Down

0 comments on commit a3b36b1

Please # to comment.