lundi 11 juillet 2016

Python: concurrent.futures: cancel not possible


This little snippets prints False import subprocess from concurrent import futures with futures.ThreadPoolExecutor(max_workers=1) as executor: future=executor.submit(subprocess.call, ['sleep', '2']) print(future.cancel()) According to the docs this means "future can't be canceled": https://docs.python.org/3/library/concurrent.futures.html#concurrent.futures.Future.cancel cancel(): Attempt to cancel the call. If the call is currently being executed and cannot be cancelled then the method will return False, otherwise the call will be cancelled and the method will return True. Is there a way to cancel the future although the cancel() methods tells me it can't be canceled? I am running the backport on Python 2.7

Aucun commentaire:

Enregistrer un commentaire