Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x aiohttp-套接字传输上的致命读取错误-TimeoutError_Python 3.x_Asynchronous_Aiohttp - Fatal编程技术网

Python 3.x aiohttp-套接字传输上的致命读取错误-TimeoutError

Python 3.x aiohttp-套接字传输上的致命读取错误-TimeoutError,python-3.x,asynchronous,aiohttp,Python 3.x,Asynchronous,Aiohttp,我们使用aiohttp和Python3.5将数据发布到弹性搜索中。帖子行如下: response = await self._http_session.request(method, url, data = data_fun(), params = params) 通常,一切运行正常,但有时会出现以下错误: Fatal read error on socket transport protocol: <aiohttp.parsers.StreamP

我们使用aiohttp和Python3.5将数据发布到弹性搜索中。帖子行如下:

response = await self._http_session.request(method, url,
                    data = data_fun(), params = params)
通常,一切运行正常,但有时会出现以下错误:

Fatal read error on socket transport
protocol: <aiohttp.parsers.StreamProtocol object at 0x7fde5eb7eeb8>
transport: <_SelectorSocketTransport fd=21 read=polling write=<polling, bufsize=261832>>
Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/selector_events.py", line 664, in _read_ready
   data = self._sock.recv(self.max_size)
TimeoutError: [Errno 110] Connection timed out
套接字传输上的
致命读取错误
协议:它随后调用
调用异常处理程序


此异常是否可能导致
\u https\u会话
无效/不可用,我们需要创建新会话?或者我们还可以做些什么吗?

TimeoutError
应该关闭
ClientSession
的一个连接。会议本身继续发挥作用

也许您也应该在代码中捕获异常

抱歉,如果不查看源代码,将无法编写更多内容

附言。 为什么不使用
async with
语句来控制响应生存期


是的,在这种情况下应该使用async with,这将改变这一点。完整的代码可以在这里找到-。这个错误实际上被我们的except子句抓住了,它应该很好。顺便问一下,你知道所有的存在吗?
async with self._http_session.request(method, url,
        data = data_fun(), params = params) as response:
    ...