[🐛 Bug]: [Exception ignored in: <function Service.__del__ at ...] Problem with Services.__del__... driver inside Class
See original GitHub issueWhat happened?
I’m studying the Page Object Model (POM), to package the driver, all the features and operations needed to do scrapping… I used to do it through scripts, without using Class and Object Oriented Programming concepts.
However, when creating the driver in the init of a Class, I get an error <function Service.del at 0x000001AD36775CF0>
Tested on Wi10 and PopOS 22.04. In both Operating Systems gives error.
Evaluating the del function, I didn’t understand why it is called, when I use the driver in the init of a Class
def __del__(self) -> None:
# `subprocess.Popen` doesn't send signal on `__del__`;
# so we attempt to close the launched process when `__del__`
# is triggered.
# do not use globals here; interpreter shutdown may have already cleaned them up
# and they would be `None`. This goes for anything this method is referencing internally.
try:
self.stop()
except Exception:
pass
I found similar error in: https://github.com/seleniumhq/selenium/issues/1504
How can we reproduce the issue?
import time
from pathlib import Path
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from traquitanas.scrapping import gecko # To Download Gecko Driver and Get Path to Gecko
# Base Path
project_path = Path(__file__).absolute().parents[1]
print(project_path)
# Create Paths
scrapy_path = project_path / 'scrapy'
scrapy_path.mkdir(exist_ok=True)
driver_path = scrapy_path / 'driver'
driver_path.mkdir(exist_ok=True)
logs_path = scrapy_path / 'logs'
logs_path.mkdir(exist_ok=True)
# Set Class
class Driver:
def __init__(self, driver_path, logs_path):
# Services
service = FirefoxService(
executable_path=gecko.get_path_geckodriver(
driver_path, verify_ssl=True
),
log_path=logs_path / 'geckodriver.log',
)
# Driver
self._driver = webdriver.Firefox(service=service)
def login(self, url):
# Get URL
self._driver.get(url)
def fechar(self):
self._driver.quit()
# Classe
page = Driver(driver_path, logs_path)
page.login('https://github.com/')
# Do Something
# Close Connection
time.sleep(2)
page.fechar()
Relevant log output
Exception ignored in: <function Service.__del__ at 0x0000023A31F39CF0>
Traceback (most recent call last):
File "C:\Users\michelsilva\Documents\Apps\Miniconda\envs\pablocarreira-lastest\lib\site-packages\selenium\webdriver\common\service.py", line 177, in __del__
AttributeError: 'NoneType' object has no attribute 'suppress'
Operating System
Windows 10 or PopOS 22.04
Selenium version
4.6.0
What are the browser(s) and version(s) where you see this issue?
Firefox 107.0 64 bits
What are the browser driver(s) and version(s) where you see this issue?
GeckoDriver 0.32
Are you using Selenium Grid?
No
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Python: Exception ignored in: <bound method Service ...
Trying to create html objects for further processing. The following is the output: Exception ignored in: <bound method Service.__del__ of < ...
Read more >Python: clean-up error in Chrome / IE "Service" in selenium ...
This common base class now contains a "del" method (which is not a bad thing in itself). However if the driver was quit...
Read more >7. WebDriver API — Selenium Python Bindings 2 documentation
An internal error occurred int the extension. Might be caused by bad input or bugs in webdriver. class selenium.webdriver.firefox.extension_connection.
Read more >Resolve "ERROR : Internal Service Exception" in AWS Glue
My AWS Glue crawler fails with the error "ERROR : Internal Service Exception". Resolution. Crawler internal service exceptions are sometimes ...
Read more >selenium - chromedriver executable needs to be in PATH
I was trying to code a script using selenium in pycharm, however, the error above occurred. I am new to selenium, isn't chrome...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Tks, Already tested! Not more errors!!!
Released in https://pypi.org/project/selenium/4.6.1/ a few minutes ago. This ticket can be closed.