gpt4 book ai didi

python - 为什么我会收到很多关于 chromedriver 的 ConnectionResetErrors?

转载 作者:太空宇宙 更新时间:2023-11-04 04:14:17 27 4
gpt4 key购买 nike

当使用 selenium 和 chromedriver 在 django 站点上运行测试时,我收到很多 ConnectionResetErrors。完整的错误输出包含在底部。请注意,即使如此,测试也能顺利通过 - 问题是控制台中出现大量异常消息。使用 geckodriver 时不会发生 ConnectionResetErrors。如果我运行任何一个测试,错误就不会发生,但是当我运行所有测试时,控制台输出就会充满这些错误。

我已经查看了类似问题的答案,但我没能找到任何适用的好的解决方案。

我的测试用例扩展了一个处理 setUp 和 tearDown 的公共(public)类。这个通用类又扩展了 StaticLiveServerTestCase。

setUp方法的相关部分是:

self.chromedriver = chrome.webdriver.WebDriver(executable_path=r"chromedriver.exe")
self.chromedriver.implicitly_wait(10)

没有其他代码行影响 self.chromedriver 对象的配置。

我尝试在 tearDown 方法中调用 self.chromedriver.quit(),但这似乎只会导致更多相同类型的错误消息。当运行单个测试时,它还会导致出现错误消息。

是什么导致了大量的 ConnectionResetErrors?

版本是:

> python -c "import selenium; print(selenium.__version__)"
3.141.0

Chrome :73.0.3683.103

> chromedriver --version
ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72)

Windows 10 操作系统内部版本 16299.1087

> python --version
Python 3.7.2


> django-admin --version
2.1.7

编辑:我无法确定问题的确切原因,但它似乎与使用 chromedriver 和 Django 的 LiveServerTestCase 有关。现在,我已经停止使用 LiveServerTestCase。相反,我使用 Python UnitTest 并单独处理测试数据库设置和 Django wsgi 服务器启动。

带有显式退出的一个测试的完整控制台输出:

> py manage.py test main.tests.test_pages.test_request_help
Creating test database for alias 'default'...
System check identified no issues (0 silenced).

DevTools listening on ws://127.0.0.1:54845/devtools/browser/1c099597-7692-4fe8-b463-783e501f1853
Testing request help page using driver chrome
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 54863)
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 54873)
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 54862)
Exception happened during processing of request from ('127.0.0.1', 54872)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 54871)
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
self.handle_one_request()
----------------------------------------
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
----------------------------------------
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
.
----------------------------------------------------------------------
Ran 1 test in 9.580s

OK
Destroying test database for alias 'default'...

没有显式退出的所有测试的完整输出:

> py manage.py test
Creating test database for alias 'default'...
System check identified no issues (0 silenced).

DevTools listening on ws://127.0.0.1:55279/devtools/browser/78eed288-e607-442a-8657-4439409d5692
Testing about page using driver chrome
.
DevTools listening on ws://127.0.0.1:55309/devtools/browser/2190ae47-c711-41fa-922f-9115d50065fd
Testing home page using driver chrome
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55297)
----------------------------------------
Traceback (most recent call last):
Exception happened during processing of request from ('127.0.0.1', 55294)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
----------------------------------------
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
.
DevTools listening on ws://127.0.0.1:55354/devtools/browser/e94aab0a-fb6b-4950-b8b9-ccee2c601cfa
Testing home page using driver chrome
.
DevTools listening on ws://127.0.0.1:55380/devtools/browser/d82461dc-4436-4d81-b21e-4091e9412225
Testing home page using driver chrome
.
DevTools listening on ws://127.0.0.1:55410/devtools/browser/e7b13108-1259-4094-a8be-7963e19d549d
Testing navbar using driver chrome
.
DevTools listening on ws://127.0.0.1:55444/devtools/browser/941ec710-590f-49f1-9aca-912dd453ae8e
Testing request help page using driver chrome
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55370)
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
----------------------------------------
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55372)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
Exception happened during processing of request from ('127.0.0.1', 55368)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
----------------------------------------
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
----------------------------------------
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55395)
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55429)
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55425)
Exception happened during processing of request from ('127.0.0.1', 55430)
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55428)
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
Traceback (most recent call last):
Traceback (most recent call last):
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 169, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
----------------------------------------
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request
self.raw_requestline = self.rfile.readline(65537)
File "C:\Users\[redacted]\AppData\Local\Programs\Python\Python37-32\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
----------------------------------------
.
----------------------------------------------------------------------
Ran 6 tests in 38.146s

OK
Destroying test database for alias 'default'...

最佳答案

An existing connection was forcibly closed by the remote host

此错误消息表示“此处已存在一个连接,您正试图打开另一个连接。”。也许您的其中一个关系还活着或卡住了。

您应该在 Debug模式下针对此问题分析您的代码,并尝试找出您的代码的哪些区域正在这样做。找到后,尝试等待关闭打开的连接。

关于python - 为什么我会收到很多关于 chromedriver 的 ConnectionResetErrors?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55728805/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com