Search code examples
pythonseleniumselenium-webdriverpython-multiprocessingubuntu-18.04

How to manage several selenium scripts running at once on VDS?


Currently, I have two python bots running on VDS, both of them are using selenium and running headless chrome to get dynamically generated content. While there was only one script, there was no problem, but now, it appears that the two scripts fight for the chrome process (or driver?) and only get it once the other one is done.
Have to mention, that in both scripts, Webdriver is instantiated and closed within a function, that itself is ran inside a Process of multiprocessing python module. Running in virtual environment didn't do anything, each script has their own file of chrome driver in their respective directories, and by using ps -a I found that there are two different processes of chromedriver running and closing, so I am positive that scripts aren't using the same chrome.
Sometimes, the error says "session not started" and sometimes "window already closed".

My question is - how do I properly configure everything, so that the scripts don't interfere with each other?


Solution

  • For anyone having the same problem - double-triple-quadriple-check that the function, that you're passing in the Process, is the one instantiating Webdriver. I can't believe this problem is fixed just like that.