Skip to content

Commit

Permalink
Merge pull request #86 from KotlinIsland/something
Browse files Browse the repository at this point in the history
Cancel future when process is canceled
  • Loading branch information
leinardi authored Feb 19, 2022
2 parents a963665 + 175dc63 commit 3da05cb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/com/leinardi/pycharm/mypy/util/Async.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.leinardi.pycharm.mypy.util;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.progress.ProcessCanceledException;
import com.intellij.openapi.progress.ProgressManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -47,7 +48,12 @@ public static <T> Future<T> executeOnPooledThread(final Callable<T> callable) {

public static <T> Future<T> whenFinished(final Future<T> future) {
while (!future.isDone() && !future.isCancelled()) {
ProgressManager.checkCanceled();
try {
ProgressManager.checkCanceled();
} catch (ProcessCanceledException e) {
future.cancel(true);
throw e;
}
waitFor(FIFTY_MS);
}
return future;
Expand Down

0 comments on commit 3da05cb

Please sign in to comment.