[🚀 Feature]: Service
shutting down via __del__
is unintuitive (as Remote
only consumes the service url)
#14464
Labels
Service
shutting down via __del__
is unintuitive (as Remote
only consumes the service url)
#14464
Feature and motivation
I recently faced a weird bug where returning from a function would cause the browser to close and Selenium to complain they couldn't reach the driver. Turned out, my
Service
was garbage collected (and quitting it via__del__
) after I had used itsservice_url
.While in hindsight it is expected behavior based on the code (I did not pass
webdriver_service
, I passed a string I got from it), it's not very weird (especially if you don't know the internals of how webdrivers work) to overlook the.service_url
and assume thatRemote
would setwebdriver_service
as an instance attribute, keeping it from being garbage collected.This behavior is in my opinion very unintuitive. A possible solution would be to only allow passing the whole
Service
intoRemote
instead of just theservice_url
(and setting it as an instance attribute), but this would be backwards-incompatible. Maybe add another method for passing the wholeService
(or overload the original method), and encourage using that (for example by raising a warning when theservice_url
parameter is accessed) instead of theservice_url
? I don't have a good proposal, but I thought I would submit an issue anyway, since it cost me a lot of time to debug.After writing this, it came to mind that using
Service
andRemote
directly might not have been intended anyway. The readme ofwebdriver-manager
told me to do it this way, probably because Opera was deprecated. I'll submit it anyway, but if this is the case, it's probably a lot less important.Usage example
Not applicable
The text was updated successfully, but these errors were encountered: