Process (create, start, join)
Basic Process usage
basic_process.py
from multiprocessing import Process
def work(name: str) -> None:
print("Working in process:", name)
if __name__ == "__main__":
p = Process(target=work, args=("p1",))
p.start()
p.join()
print("Main process finished")basic_process.py
from multiprocessing import Process
def work(name: str) -> None:
print("Working in process:", name)
if __name__ == "__main__":
p = Process(target=work, args=("p1",))
p.start()
p.join()
print("Main process finished")Why join() matters
join()join() waits for the process to finish.
Without it:
- your program might exit early
- you might read results before they are ready
🧪 Try It Yourself
Exercise 1 – Start a Process
Exercise 2 – Process Pool map()
Exercise 3 – Multiprocessing Queue
If this helped you, consider buying me a coffee ☕
Buy me a coffeeWas this page helpful?
Let us know how we did
