运行此代码时,其中一个硒窗口未关闭
import multiprocessing
from selenium import webdriver
class Worker:
def __init__(self):
self.driver = webdriver.Chrome()
def run(self):
self.driver.get('https://www.google.com')
processes = []
for i in range(2):
worker = Worker()
process = multiprocessing.Process(target=worker.run)
process.start()
processes.append(process)
for any_name in processes:
any_name.terminate()
但是如果我将变量名从any_name
更改为worker
,则所有硒窗口都将关闭。为什么会这样?
PS版本:python 3.7,chromedriver 83,硒3.141.0