Here is my issue: I am at this point in a class that we are going over multiple processes in Python using jupyter notebook. I have everything typed the same as the instructor has it. I installed the package as well. However, I get a solution of {} instead of what she is showing on her screen.
Okay so, the instructor suggested that we install the multiprocess package. We do this from the command prompt: pip install multiprocess
Here are my results (since I already installed it last week): C:\Users\sevan\OneDrive\Documents\PythonEssentialTraining\Exercise Files\exercise_files>pip install multiprocess Requirement already satisfied: multiprocess in c:\users\sevan\appdata\local\programs\python\python311\lib\site-packages (0.70.15) Requirement already satisfied: dill>=0.3.7 in c:\users\sevan\appdata\local\programs\python\python311\lib\site-packages (from multiprocess) (0.3.7)
NO big surprise, everything looks like it was successful from what I can understand (I am new to command lines and Python, 3 weeks old here and just in a beginners class).
Now, she tells us to import the process library and the time library into jupyter (I call it a library as that is what R called it back in the day):
from multiprocess import Process
import time
Then I typed in the following according to her screen:
def longSquare(num, results):
time.sleep(1)
print(num**2)
results = {}
p1 = Process(target=longSquare, args=(1,results))
p2 = Process(target=longSquare, args=(2,results))
p1.start()
p2.start()
p1.join()
p2.join()
print(results)
When I type CTRL+Enter, I get
{}
What her screen is showing is
14
{}
I do not know what I have done wrong?
Now, this is an example of a multiprocess, it is not a perfect one. She explains that the 14 should not look like that later in the lesson. What I need is for jupyter notebook to print out the 14 and {}. Any suggestions?
This is probably super easy. Also, I have shut down all other processes in the notebook, any other notebooks, maybe something else is going on in the background? Also, I get no errors and it does not seem to be hanging as when I add 1+1 at the end, it gives me 2, as that's my test to see if something is hanging.
Thanks in advance.