Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

trying to open run task on multi browser profiles parallel #3348

iMADzero0 started this conversation in General
Discussion options

from seleniumbase import SB
import time
import os
import threading
from concurrent.futures import ThreadPoolExecutor
def open(id):
 
 Profile_Path = fr"C:\Users\{os.getlogin()}\Dev\ConnectBoite\Profiles\{id}"
 Bnry_Path = fr"C:\Users\{os.getlogin()}\Dev\iBot\browser\chrome.exe"
 
 with SB(uc=True, user_data_dir=Profile_Path, binary_location=Bnry_Path) as sb:
 url = "https://pixelscan.net"
 sb.open(url)
 sb.sleep(2*60)
if __name__ == '__main__':
 
 Profiles = ['P1','P2','P3']
 
 
 # with ThreadPoolExecutor(max_workers=3,thread_name_prefix="TaskThread_",initializer=lambda: print("Initializing worker...")) as executor:
 # for p in Profiles:
 # executor.submit(open, p)
 
 threads = []
 for profile in Profiles:
 t = threading.Thread(target=open, args=(profile,))
 threads.append(t)
 t.start()
 for t in threads:
 t.join()

Hi,

If anyone has any ideas or can help me fix my code, I would really appreciate it. I'm trying to open multiple profiles and run tasks in parallel on all of them, but I keep getting an error, or the task only runs on one profile.

I previously used undetected-chromedriver and fixed the issue by passing a unique driver for each profile. Now, I’m trying to use seleniumbase but haven’t found a way to pass a unique driver for each profile. Does anyone know how I can run tasks in parallel across multiple profiles using seleniumbase?

Screenshot 2024年12月17日 221350

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

See the section on proper multithreading in the UC Mode docs:

from concurrent.futures import ThreadPoolExecutor

Also, you can only set the user_data_dir (Not the Profile). The Default profile must always be used.

You must be logged in to vote
1 reply
Comment options

thank u sir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /