-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[py] Allow Service
as command_executor
in Remote.__init__
#16273
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
base: trunk
Are you sure you want to change the base?
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Thanks.. I re-opened the original issue. hmm... what if we added an additional kwarg to The default would be service.Service("operadriver", auto_stop=False) Then inside def __del__(self) -> None:
try:
if self.auto_stop:
self.stop()
except Exception:
pass Would that solve the original problem? |
Then the |
Small clarification; I don't mean this is a bad idea always, but having to use this to avoid GC is unnecessary IMO. I think my solution results in much cleaner user code, and I would still prefer to see a solution that (as I said) can be applied everywhere; but if that isn't possible that's the next best solution. |
Yes, my suggestion would require you to explicitly stop the service. Your solution adds a classmethod to the base class of all webdrivers that directly instantiates the There might be a nice implicit solution to this, but the current code in your PR isn't it. |
It does not?? |
It also does not instantiate a |
It does.
|
You're right, apologies. I expected that to be But that means there is currently no isolated subclass for a |
Then |
I mean, yea we could reorganize the class hierarchy to make this work. It's just not a trivial change and I don't want to break any existing code relying on the current API. I'm not sure it's worth it just to address a somewhat uncommon use case that we have never really had complaints about before. |
Yep I get it! I was under the impression that I was on the verge of closing this but one more idea came to me. What if
|
Service
as command_executor
in Remote.__init__
Implemented, the documentation might need to be improved. I don't know what the standards for types and such are. |
User description
🔗 Related Issues
Closes #14464
Ping @cgoldberg
💥 What does this PR do?
Adds
Remote(service)
as an alternative forRemote(service.service_url)
. It makes sure theService
doesn't get garbage collected.Example:
🔧 Implementation Notes
Added a test that confirms the time at which the
Service
is dropped, and that any arguments are passed through correctly.💡 Additional Considerations
Ideally, all code currently using
Remote(service.service_url)
should change toRemote(service)
. This could in theory be warned for by Selenium, but that would involve makingservice_url
some kind ofstr
wrapper.🔄 Types of changes
PR Type
Enhancement
Description
Add
Remote.from_service
class method for better service lifecycle managementPrevent service garbage collection by maintaining reference in Remote instance
Include comprehensive test for service lifecycle and argument passing
Diagram Walkthrough
File Walkthrough
webdriver.py
Add from_service class method
py/selenium/webdriver/remote/webdriver.py
from_service
class method to Remote classSelf
type andService
classfrom_server_tests.py
Add comprehensive from_service tests
py/test/unit/selenium/webdriver/remote/from_server_tests.py