-
I've had to switch a large application over from undetected_chromedriver to Seleniumbase, by basically replacing:
with
And everything works great, at least for a single process. However when we get up to a few hundred concurrent instantiations of the webdriver running, we get the error:
I think it's process or port collision maybe? With UC we use the subprocess feature, and I'm running hundreds of simultaneous instances on a large Ubuntu 22.04 server, each from it's own directory (so we can track and kill rogue processes by path). So the question is, what's the best practice for large production usage of Seleniumbase as a replacement for webdriver, without the pytest multi-processing? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
For large-scale production multithreading, pytest-xdist is so far the only reliable way to make it work (Eg. I talked about that here: #2006 (comment) If I figured out a way to make massive multithreading with UC Mode work at scale reliably without requiring I do have a question for others: What's wrong with using |
Beta Was this translation helpful? Give feedback.
-
I'm using cron to launch a Python application every few minutes, the application is stand-alone, and in it's own directory, which is parallel to dozens of others. The problem is the processes are running on the same server, but not being launched from the same instantiation at the same time. I had this same problem with uc years ago. I'm not sure what chrome is doing, but it leaves a lot of processes hung up when the bot crashes, and they eventually load up and kill the application, or it's ability to talk to chrome. Here's my brutal fix that's working, but I would certainly prefer better process management to this:
As you can see, I'm literally just killing old processes, regardless of which might still be doing their job, but these are the ones left hanging open. How does pytest control chrome's processes within Seleniumbase differently,? There is a lot of interest in Seleniumbase as a more to robust solution compared to uc and selenium, especially as it's working for Cloudflare when uc isn't (at the moment), the fact that it's basically a drop-in replacement for all of us coming from raw selenium or uc is awesome, but many of us are obviously not using SeleniumBase for "testing" and thus might not be so inclined to refactor to utilize pytest. |
Beta Was this translation helpful? Give feedback.
-
Actually I'm a glutton for punishment and efficiency, so I'm experimenting with building a single application launcher that will take advantage of the pytest threading library. However, I don't fully understand exactly which processes headless chrome spins up, or for what purpose. But you've seen the pytest utilization handling very large concurrency with Seleniumbase successfully? Like over a few hundred? |
Beta Was this translation helpful? Give feedback.
For large-scale production multithreading, pytest-xdist is so far the only reliable way to make it work (Eg.
pytest -n8
for 8 SeleniumBase threads). That library contains some powerful code to keep resources from overlapping each other.I talked about that here: #2006 (comment)
If I figured out a way to make massive multithreading with UC Mode work at scale reliably without requiring
pytest
, then I would definitely post something about it.I do have a question for others: What's wrong with using
pytest
as a test runner? There shouldn't be any limitations with using it.