[py] speed up Service launch (sleep depending on the number of attempts to check if the service has started) #13321
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Python client. Problem file: py/selenium/webdriver/common/service.py
When the driver is initialized, the service starts, and then a loop checks to see if it has started.
But there is a constant delay of 0.5 seconds in the loop. Here the delay logic changes - instead of the constant 0.5 seconds, it increases in increments of 0.05, starting at 0.01 and going up to 0.5.
Motivation and Context
When a driver with many options is started, there is a 0.5 second delay. For one request it is not noticeable, but for many requests, when it is necessary to initialize the driver each time, it results in significant time loss.
Line_profiler
Reproduce the problem
test.py
Edit selenium/webdriver/common/service.py - remove sleep and logging where service will be started:
run test.py
Here we see that the startup time is <= 0.01.
So there is no point in waiting for 0.5 seconds, it is just a waste of time.
Types of changes
Checklist