Skip to content

Instantly share code, notes, and snippets.

@paulwinex
Created June 13, 2020 17:43
Show Gist options
  • Save paulwinex/c6ee848bed5f8c96b83c26ffdf6a3882 to your computer and use it in GitHub Desktop.
Save paulwinex/c6ee848bed5f8c96b83c26ffdf6a3882 to your computer and use it in GitHub Desktop.
from concurrent.futures import ProcessPoolExecutor
import multiprocessing
def infinite_compute(a):
print('Core', a)
while True:
x = 2 * 2
print('Ctrl+C to exit')
try:
with ProcessPoolExecutor() as executor:
executor.map(infinite_compute, list(range(multiprocessing.cpu_count())))
except KeyboardInterrupt:
exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment