我必须运行所有 50 个 chrome。我想总是同时运行 5 个 chrome。如果 1 in 5 chrome 先关闭,它将运行 1 chrome new。直到 50 镀铬完成。
示例:5 chrome 正在运行。如果 chrome 3 先关闭,chrome 6 将运行。所以它总是同时运行 5 个 chrome。
我该怎么做?
run_chrome = 50
thread = 5
def run_thread(thread_amount):
my_thread = []
for i in range(thread_amount):
my_thread.append(threading.Thread(target=run_chrome_browser, args=[]))
for t in my_thread:
t.start()
for t in my_thread:
t.join()
while thread < run_chrome:
run_thread(thread)
run_chrome = run_chrome - thread
run_thread(run_chrome)