python 下用selenium打开phantomjs出错,请问如何处理 10
展开全部
6down voteaccepted
The reason for this behavior is how the PhantomJS driver's Service class is implemented.
There is a __del__ method defined that calls self.stop() method:
def __del__(self):
# subprocess.Popen doesn't send signal on __del__;
# we have to try to stop the launched process.
self.stop()
And, self.stop() is assuming the service instance is still alive trying to access it's attributes:
def stop(self):
"""
Cleans up the process
"""
if self._log:
self._log.close()
self._log = None
#If its dead dont worry
if self.process is None:
return
...
The same exact problem is perfectly described in this thread:
Python attributeError on __del__
What you should do is to silently ignore AttributeError occurring while quitting the driver instance:
try:
driver.quit()
except AttributeError:
pass
The problem was introduced by this revision. Which means that downgrading to 2.40.0 would also help.
The reason for this behavior is how the PhantomJS driver's Service class is implemented.
There is a __del__ method defined that calls self.stop() method:
def __del__(self):
# subprocess.Popen doesn't send signal on __del__;
# we have to try to stop the launched process.
self.stop()
And, self.stop() is assuming the service instance is still alive trying to access it's attributes:
def stop(self):
"""
Cleans up the process
"""
if self._log:
self._log.close()
self._log = None
#If its dead dont worry
if self.process is None:
return
...
The same exact problem is perfectly described in this thread:
Python attributeError on __del__
What you should do is to silently ignore AttributeError occurring while quitting the driver instance:
try:
driver.quit()
except AttributeError:
pass
The problem was introduced by this revision. Which means that downgrading to 2.40.0 would also help.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询