I am new in python i have Anaconda Pyton 3.9 I was studying about Multiprocessing.
When i try this code
from multiprocessing import Process # gerekli kütüphaneyi çağıracağız.
import time
def subfunc1():
time.sleep(2)
print("subfunc1: Baslatildi")
time.sleep(2)
print("subfunc1: Sonlandi")
time.sleep(2)
def subfunc2():
time.sleep(2)
print("subfunc2: Baslatildi")
time.sleep(2)
print("subfunc2: Sonlandi")
time.sleep(2)
def mainfunc():
print("mainfunc: Baslatildi")
pr1 = Process(target=subfunc1)
pr2 = Process(target=subfunc2)
pr1.start()
pr2.start()
print("mainfunc: Sonlandi")
if __name__ == '__main__': # Main kod bloğunun içerisindeyken main fonk çağır!
mainfunc()
result is
mainfunc: Baslatildi
mainfunc: Sonlandi
When i use Visual Code with Python 3.9 i have a virtual and code works! Visual Code uses Anaconda's python 3.9 within a virtual env!
Could you please help me? Whey this code can't work properly in Jupyter Notebook?
Thanks
source https://stackoverflow.com/questions/73437156/jupyter-notebook-multiprocessing-code-not-working
Comments
Post a Comment