python-eel / Eel

A little Python library for making simple Electron-like HTML/JS GUI apps
MIT License
6.38k stars 583 forks source link

THREADING ERROR #541

Open FranciscoPalomares opened 2 years ago

FranciscoPalomares commented 2 years ago

Im trying to execute two selenium in differente threads, but it executed one and then the second:

from seleniumwire import webdriver
from webdriver_manager.chrome import ChromeDriverManager
import eel
eel.init('web')

def my_other_thread(numero):
    '''while True:
        print("I'm a thread " + numero)
        eel.sleep(1.0)                  # Use eel.sleep(), not time.sleep()
    '''

    eel.sleep(1.0)
    driver = webdriver.Chrome(
        ChromeDriverManager().install())

    driver.get("https://www.google.com")

    for i in range(6):
        driver.get(driver.current_url)

eel.spawn(my_other_thread, "1")

eel.spawn(my_other_thread, "2")

eel.start('main.html', block=False)     # Don't block on this call

while True:
    print("I'm a main loop")
    eel.sleep(1.0)