Help, please, enable multiprocessing in Jupyter, threading- for obvious reasons, it does not really help me, just, for example, I will leave it.
The second example in my mind had to speed everything up 4 times, since there are 4 physical cores on my laptop, but something went wrong, sort of, by analogy with threading, but it does not work.
import threading import time a = [] def func(arg): time.sleep(1) a.append(arg) for file in range(100): threading.Thread(target=func, args=([1])).start() time.sleep(2) print(a) after 2 seconds, everything works.
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 , 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ]
from multiprocessing import Process import time a = [] def func(arg): time.sleep(1) a.append(arg) for file in range(4): Process(target=func, args=([1])).start() time.sleep(2) print(a) []