From the course: Python Essential Training
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Multiprocessing - Python Tutorial
From the course: Python Essential Training
Multiprocessing
You're probably great at multiprocessing in Python already and don't even know it. Here, I'll show you. I have a file called 1000seconds.py. All it does is call time.sleep for 1000 seconds. So I'm going to open a second tab and run it in the second tab. So now we have two tabs running this program. Great! Two Python processes running independently on my machine. Multiprocessing in Python. All right, so that's how you do that. the next subject then? Just kidding. Yes, I do have two separate Python processes running, but I had to start them by hand. How do we write a program to start, stop, and manage these for us? Well, conveniently, there's a module that's very similar to the threading module we used previously. Let's check it out. And that module is called multiprocessing. From multiprocessing import process. Okay, so before I run this, there is a small hitch with using the official Python multiprocessing module. On some operating systems, you can't use this to spin up a new process…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.