I am performing multiprocessing in Python. In Python, there are two classes, Pool and Process, to perform multiprocessing. The class Pool executes the processes on multiple cores depending on the availability of the cores.
I wanted to know whether the Process class executes the processes in parallel on multiple cores or on a single core??
Short answer: it runs on a different process.
When you instantiate a Process
object, after calling the method start()
the current process is going to fork and the new process is going to execute the method run()
. If you have a system with multiple cores, you might indeed take advantage of this parallelism.
Note: the difference between the classes Pool
and Process
is that Pool
spawns multiple worker processes at once, whereas Process
only spawns a single process; however, both use processes that are distinct from your main process.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.