def cancel(self, job_id):
        """
        Request a cancellation from the futures executor pool.
        If that didn't work (because it's already running), then mark
        a special variable inside the future that we can check
        inside a special check_for_cancel function passed to the
        job.
        :param job_id:
        :return:
        """
        future = self.future_job_mapping[job_id]
        is_future_cancelled = future.cancel()

        if is_future_cancelled:  # success!
            return True
        else:
            if future.running():
                # Already running, but let's mark the future as cancelled
                # anyway, to make sure that calling future.result() will raise an error.
                # Our cancelling callback will then check this variable to see its state,
                # and exit if it's cancelled.
                from concurrent.futures._base import CANCELLED
                future._state = CANCELLED
                return False
            else:  # probably finished already, too late to cancel!
                return False
def cancel ( self , job_id ) : future = self . future_job_mapping [ job_id ] is_future_cancelled = future . cancel ( ) if is_future_cancelled : return True else : if future . running ( ) : from concurrent . futures . _base import CANCELLED future . _state = CANCELLED return False else : return False
Request a cancellation from the futures executor pool.
        If that didn't work (because it's already running), then mark
        a special variable inside the future that we can check
        inside a special check_for_cancel function passed to the
        job.
        :param job_id:
        :return: