Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
393 B
1
Indexable
Never
from multiprocessing import Process
import os
import time

def square_numbers():
    for i in range(100):
        i * i
        time.sleep(0.1)
        
processes = []
num_processes = os.cpu_count()

for i in range(num_processes):
    p = Process(target=square_numbers)
    processes.append(p)
    
for p in processes:
    p.start()
    
for p in processes:
    p.join()
    
print('end main')