I was using this following example to try & figure out the multiprocessing module in Python, but then I started to wonder, what happens when you try & multiproccess on a single core CPU? What exactly would happen with this following example? I assume it would run, but what exactly would be happening under the hood?
import os
import random
import sys
import time
import multiprocessing
from multiprocessing import pool
if __name__ == '__main__':
def worker(number):
sleep = random.randrange(1, 10)
time.sleep(sleep)
print("I am Worker {}, I slept for {} seconds".format(number, sleep))
for i in range(5):
t = multiprocessing.Process(target=worker, args=(i,))
t.start()
print("All Processes are queued, let's see when they finish!")