private static void waitForTask(@NotNull CanceledStatus status, Future<?> task) {
    try {
      while (true) {
        try {
          task.get(500L, TimeUnit.MILLISECONDS);
          break;
        }
        catch (TimeoutException ignored) {
          if (status.isCanceled()) {
            break;
          }
        }
      }
    }
    catch (Throwable th) {
      LOG.info(th);
    }
  }
private static void waitForTask(@NotNull CanceledStatus status, Future<?> task)