Skip to content
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

Close DriverService and DriverCommandExecutor executor on quit #9677

Merged

Conversation

pujagani
Copy link
Contributor

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Fixes #9666

Motivation and Context

A dedicated thread pool is provided for DriverService's async calls. The thread pool was initially not closed after the session is quit. The changes fix that.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@sonarcloud
Copy link

sonarcloud bot commented Jul 23, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@pujagani pujagani changed the title Close DriverService executor on quit Close DriverService and DriverCommandExecutor executor on quit Jul 23, 2021
@pujagani pujagani mentioned this pull request Jul 23, 2021
@pujagani pujagani merged commit 7a63077 into SeleniumHQ:trunk Jul 23, 2021
@asolntsev
Copy link
Contributor

asolntsev commented Nov 19, 2021

@pujagani Hi!
May I ask you, did you have a good reason to use executorService.shutdownNow(), not executorService.shutdown()?
It seems reasonable to wait for completion of already started tasks.

I am not sure yet, but probably it cases #9784 (comment).

UPD @pujagani I prepared a pull request #10063 for replacing shutdownNow with shutdown, do you see any problems with this change?

@pujagani
Copy link
Contributor Author

@asolntsev Thank you for your contribution and effort. I think it's not the best idea to use shutDown() as it is. Long-running threads might prevent the shutdown from happening in time. Might be better to use awaitTermination() along with the same with a timeout value.

@asolntsev
Copy link
Contributor

asolntsev commented Nov 22, 2021

@pujagani I agree, we should use combination of shutdown + awaitTermination. Now lot of flaky tests in Selenium itself and Selenide as well are caused by the fact that we don't wait until Firefox is properly closed.

@pujagani
Copy link
Contributor Author

I am glad your changes help fix that. Thank you!

@sonali9293
Copy link

sonali9293 commented Apr 27, 2022

@pujagani @diemol - Hi, my tests are getting skipped and I am getting the below. I believe this could be because of this same leakage issue ? Using Selenium 4.1.3. Could you please take a look at [https://github.com/testng-team/testng-eclipse/issues/534]
ERROR
'[AsyncHttpClient-1-5] ERROR org.asynchttpclient.netty.request.NettyRequestSender - Can't write request
[AsyncHttpClient-1-4] ERROR org.asynchttpclient.netty.request.NettyRequestSender - Can't write request
java.io.IOException: Stream closed'

@diemol
Copy link
Member

diemol commented Apr 27, 2022

@sonali9293 if you are having an issue, please create a new one filling out all the details in the template.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Selenium leaks Threads
4 participants