Issues on creating multiple browser windows

56 views
Skip to first unread message

Jose

unread,
Mar 23, 2022, 3:09:38 PM3/23/22
to CEF Python
I'm attempting to create multiple browser windows within a single python program.

Those must be completely separate, including it's "user_agent", "user_data_path" (and maybe browser switches if possible). my current attempt was running in 2 threads as:
Thread(target=asyncio.run, args=(createPlayer('PathToFolder1', 'www.youtube.com'),)).start()
Thread(target=asyncio.run, args=(createPlayer('PathToFolder2', 'www.youtube.com'),)).start()

each createPlayer() function has it's own Initialize(), CreateBrowserSync(), MessageLoop() and Shutdown()

but that way I get a "cefpython.CreateBrowserSync() may only be called on the UI thread" error

Managed to open 2 windows on previous attempts but those ended up using the same cache folder despite the folder being settled different inside the createPlayer() function.

Does anyone have a clue on how to create 2 browser windows (with different cache folders) in any way in python?

Czarek Tomczak.

unread,
Mar 24, 2022, 9:12:36 AM3/24/22
to CEF Python
You can call Initialize, Shutdown and MessageLoop only once during app lifetime. From what I read you call it twice.
CreateBrowserSync must be called on UI thread. If running single threaded message loop UI thread is Main thread. If running multi threaded message loop use PostTask function to run on UI thread.
Reply all
Reply to author
Forward
0 new messages