我在调试代码时遇到麻烦,因为我无法理解所引发的套接字错误。这是回溯。
Traceback (most recent call last):
File "clickpression.py", line 517, in <module> presser.main()
File "clickpression.py", line 391, in main
File "clickpression.py", line 121, in clickpress self.refresh_proxies(country=country)
File "clickpression.py", line 458, in refresh_proxies self.proxies = self.get_proxies(country=country)
File "helpers.py", line 72, in wrapper return func(*args, **kwargs)
File "clickpression.py", line 264, in get_proxies self.settings.SUPER_PROXY).read().decode('utf-8')
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 161, in urlopen return opener.open(url, data, timeout)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 463, in open response = self._open(req, data)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 481, in _open '_open', req)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 441, in _call_chain result = func(*args)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 1210, in http_open return self.do_open(http.client.HTTPConnection, req)
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/urllib/request.py", line 1185, in do_open r = h.getresponse()
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 1171, in getresponse response.begin()
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 351, in begin version, status, reason = self._read_status()
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 313, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/socket.py", line 374, in readinto return self._sock.recv_into(b)
ConnectionResetError: [Errno 54] Connection reset by peer
根据errno
库,Errno 54
是errno.EXFULL
,在Python 3中,documentation被解释为exchange full
。
据我所知,Connection reset by peer
是Errno 104
,即errno.ECONNRESET
。
那么errno.EXFULL
是什么意思?以及为什么套接字使用connection reset by peer
说明而不是exchange full
引发错误。又或者两个错误errno.EXFULL
和errno.ECONNRESET
有何关系?
PS:我read errno 54
可能与http代理有关(我在代码中使用了代理)。如果是这样,如何?
根据errno
库,Errno 54
为errno.EXFULL
您是否通过检查errno.errorcode[54]
确定了?无论如何-此[[errno
库可能有问题。您可以通过查看errno.h
,例如,在系统上验证错误代码的含义。 G。借助gcc
:
gcc -xc -imacros errno.h -Wp,-P -E <(echo ECONNRESET)
另外,Python documentation说:
要将数字错误代码转换为错误消息,请使用os.strerror()。
很可能是系统上的错误号54是
ECONNRESET
,并且os.strerror(54)
将证明这一点。[现在您已验证
os.strerror(54)
返回'Exchange full',我感到困惑,为什么错误号54
和错误字符串Connection reset by peer
不匹配。如果在具有strace
或类似内容的系统上发生这种情况,我将进一步检查操作系统,通过在受影响的进程上使用strace -e network
返回哪个错误。关于您关于EXFULL的问题:其含义似乎与系统有关; e。 G。在Linux上,仅从内核中的少数几个地方返回EXFULL,当找不到可用的桥接器端口号时,唯一与网络相关的位置在br_if.c中,涉及网桥(其他位置在USB和SCSI驱动程序中)。 >