-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add withExecutor to FluentWait to support concurrent drivers in custom thread pools #8713
Conversation
FluentWait blocked and behaved unpredictably when called concurrently from multiple web driver threads managed by a custom thread pool. This commit adds the ability to pass the Executor service that manages the threads to fluent wait.
3463684
to
ccee817
Compare
It's worth noting that launching Selenium with the following Java system property forces the CompletableFuture in FluentWait to run on the calling thread.
There's no need to explicitly set the executor if you specify this property. This solves the concurrency issue with thread contention but also affects all instances where CompletableFutures are used throughout Selenium in that they would no longer run on separate threads. In some cases however, this might be a viable alternative to the withExecutor approach introduced in this PR. I guess it's good to have options. |
Hello, not an expert here This is related to #8727 isn't it? |
@thegoldgoat I think that one has the same underlying issue. I believe it to be a systemic issue in that CompleteableFutures are used throughout Selenium 4, and not just in FluentWait. |
Thanks for the response! Again, not an expert of this codebase Is this PR ready to be tested by any chance? Should I change something in my code? Thanks again! |
@thegoldgoat try launching your app with the jvm option in my earlier comment above and use a custom thread pool. See also #8525 |
Great! Thanks a lot I'll let you know if that works |
Hi, sorry for the late response. Using that options everything works, thanks a lot!! I hope the devs would investigate in this bug and consider your solution |
What is blocking this PR from being merged? |
We discuss the current implementation. And tend to revert back to legacy (blocking) implementation. |
Sorry to say this, but we decided to return back to the legacy (blocking) implementation after clients' complains. It appears that many people use suboptimal approach to manage WebDriver instances using ThreadLocal variables. And running conditions in a separate thread makes them lose their driver. So we decided to revert this change in favour of backward compatibility. |
Description
FluentWait
blocked and behaved unpredictably when called concurrently from multiple web driver threads executing in a custom thread pool. This commit adds the ability to pass the Executor service that manages the thread pool to fluent wait.Sample usage
Motivation and Context
Many tools and frameworks built on Selenium offer options for running multiple web driver instances in parallel threads. Fluent wait can block and behave unpredictabily under some conditions where concurrent calls are made by threads in custom
Executor
s. In such instances, it becomes necessary to use the custom Executor withFluentWait
's underlyingCompletableFuture
.Types of changes
Checklist