Does multiprocessing run on one core

439 views Asked by At

I'm reading on multiprocessing with selenium to see its advantages over multithreading with selenium.

I understand computers have cores, e.g. mine has 4, and that computers have logical cores, e.g. mine has 4 also.

What I'm trying to understand is that when I use multiprocessing does do it all on one core, and if so which one? as in the main core being used by my computer or other cores.

Is it also possible to choose how many processes you want on a core, and should there be a limit.

My Questions if not clear:

  1. Does multiprocessing happen all on one core

  2. Can you choose how many processes you want on a core

  3. Should there be a limit to how many processes you have on a core

    • If there should be a limit what is the best way to work this out

Here's my code:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys

import time
import multiprocessing



class go():
    def __init__(self):
        self.run()
    def run(self):
        options = webdriver.ChromeOptions()
        options.add_argument('--headless', )
        self.browser = webdriver.Chrome('chromedriver.exe',options=options)
        self.browser.get('https://www.wikipedia.org/')

        WebDriverWait(self.browser, 10).until(
            EC.presence_of_element_located((By.ID, "searchInput"))).send_keys('Python',Keys.ENTER)
        time.sleep(3)
        print('Moved To Next Section ')

        WebDriverWait(self.browser, 10).until(
            EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Computing"))).click()
        time.sleep(3)
        print('Moved To Next Section ')

        WebDriverWait(self.browser, 10).until(
            EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "People"))).click()
        time.sleep(3)

        print('Moved To Next Section ')
        WebDriverWait(self.browser, 10).until(
            EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Roller coasters"))).click()
        time.sleep(3)

        print('Moved To Next Section ')
        WebDriverWait(self.browser, 10).until(
            EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Vehicles"))).click()
        time.sleep(3)

        print('Moved To Next Section ')
        WebDriverWait(self.browser, 10).until(
            EC.presence_of_element_located((By.PARTIAL_LINK_TEXT, "Weaponry"))).click()
        time.sleep(100)



if __name__ == "__main__":

    for count in range(10):
        multiprocessing.Process(target=go).start()
1

There are 1 answers

0
sleepyhead On BEST ANSWER

Does multiprocessing happen all on one core

No

Can you choose how many processes you want on a core

No

Should there be a limit to how many processes you have on a core If there should be a limit what is the best way to work this out

This is not something you do from python code. O/S is in charge of it. For user there is virtually no limit on number of threads or processes.

And Meny Issakov is right, you should read on multiprocessing in python.