Created
March 18, 2015 05:28
-
-
Save clchiou/084b52ace48fbebe3bcc to your computer and use it in GitHub Desktop.
Exit immediately after KeyboardInterrupt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import time | |
import concurrent.futures.thread | |
from concurrent.futures import ThreadPoolExecutor, as_completed | |
with ThreadPoolExecutor(1) as executor: | |
fs = [executor.submit(time.sleep, 10)] | |
try: | |
for f in as_completed(fs): | |
f.result() | |
except KeyboardInterrupt: | |
executor._threads.clear() | |
concurrent.futures.thread._threads_queues.clear() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not work ctrl c