我正在尝试在Python中使用Selenium打开多个网页,并使用不同的帐户同时与这些页面进行交互,但是它仅在完成a1之后才开始a2。为什么它不能同时运行两个功能,所以我可以同时使用多个帐户与网站进行交互?
def function1(url,email,password):
driver = webdriver.Chrome
driver.get(website url)
# LOG IN
def function2(url,email,password):
driver = webdriver.Chrome
driver.get(website url)
# LOG IN USING DIFFERENT ACCOUNT
a1 = multiprocessing.Process(target=function1(url,email,password))
a2 = multiprocessing.Process(target=function2(url,email, password))
a1.join()
a2.join()
答案 0 :(得分:1)
您正在过程中调用该函数:
Process(target=function1(url,email,password))
function1(url,email,password)
返回None
所以您实际上是在打电话:
Process(target = None)
如何使用多重处理。
a1 = multiprocessing.Process(target=function1, args=[url, email, password])
a2 = multiprocessing.Process(target=function2, args=[url, email, password])
a1.start()
a2.start()
a1.join()
a2.join()
我还建议在这里阅读更多有关它的内容: https://sebastianraschka.com/Articles/2014_multiprocessing.html