helium icon indicating copy to clipboard operation
helium copied to clipboard

Running multiple instances in parallel

Open TheBestMoshe opened this issue 4 years ago • 4 comments

I've been using Selenium to run multiple browser windows in parallel. To do this I would simply start a new Chrome instance and place all the driver references into a list. I then send each instance to a thread to run through its instructions. However, it doesn't seem like this is possible with Helium as, as far as I can tell, there is just one global Helium instance and I need to set the driver before executing the command. However, when I run this in multiple threads, the wrong commands get called.

Is there to have multiple instances of Helium at one time?

TheBestMoshe avatar Apr 29 '20 16:04 TheBestMoshe

The easiest solution would be to use a multiprocess pool so that every process gets its only instance of helium. Another way to do it would be to extend from the base implentation class class APIImpl: from helium/_impl/__init__.py and have that create an instance for every thread. I tried this once but I had problems with the wrappers around html elements like Link, CheckBox, Image from their respective classes LinkImpl,CheckBoxImpl,ImageImpl since they use the global require_driver() that gives you the single instance.

danbaghilovici avatar Apr 29 '20 16:04 danbaghilovici

@dntzbgh is right. Helium unfortunately does not (really) support having multiple Selenium WebDrivers that are used in parallel. He's further right that to fix this, one would have to change / extend APIImpl.

It should not be too hard to implement this, but I won't have time to do it. So if you @TheBestMoshe, @dntzbgh or someone else want this feature, you'd need to implement it yourself and submit a PR. I'd be happy to merge such change. But like I said, I will not have time to do the implementation.

mherrmann avatar Apr 30 '20 06:04 mherrmann

Does anyone have updates on this? It would be essential to me to run multiple helium drivers in the same program..

iFedix avatar Jan 16 '24 08:01 iFedix

@iFedix feel free to implement and submit a PR 👍

mherrmann avatar Jan 16 '24 10:01 mherrmann