kaliiiiiiiiii / Selenium-Driverless

undetected Selenium without usage of chromedriver
https://kaliiiiiiiiii.github.io/Selenium-Driverless/
Other
520 stars 63 forks source link

RuntimeWarning: coroutine 'SwitchTo._init' was never awaited self._init() #27

Closed apatel415 closed 1 year ago

apatel415 commented 1 year ago

Hi, love your work and overall great product! However, when I try to run this in a multithreaded script I get the following error:

selenium_driverless/sync/switch_to.py:12: RuntimeWarning: coroutine 'SwitchTo._init' was never awaited self._init() RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Thoughts on work arounds or fixing this error? For reference, I am using sync version. I have a script the calls multi-processes and multi-threads within each process to scale up multiple scraper instances. It works with undetected_chromedriver, however want to see if I can use the selenium_driverless package instead.

----- Update ----- I changed self._init() in switch_to.py to self._loop.run_until_complete(self._init()), but now I get the error "This event loop is already running." Will investigate further.

kaliiiiiiiiii commented 1 year ago

I am aware of this, fix is allready out and will be in the next release. see https://github.com/kaliiiiiiiiii/Selenium-Driverless/commit/c21135058d103db43fd6147521c6c3d6feda58c7

closing for now

apatel415 commented 1 year ago

Awesome, thanks mate. I'm assuming I can't run this in Multithreading libraries (i.e. concurrent.futures.ThreadPoolExecutor()). No worries if not, I can work around it. I get error that says "This event loop is already running" so thinking combing multithread and async may be bad practice.

kaliiiiiiiiii commented 1 year ago

Awesome, thanks mate. I'm assuming I can't run this in Multithreading libraries (i.e. concurrent.futures.ThreadPoolExecutor()). No worries if not, I can work around it. I get error that says "This event loop is already running" so thinking combing multithread and async may be bad practice.

Yeah wouldn't recommend using multithreading with the syncified version. however, I've got an idea how I could support it. I'll add it to the TODO's