pyspark在windows加载数据集训练模型出现 以下错误 Connection reset by peer: socket write error

As a workaround you might try the following change to python/pyspark/worker.py

Add the following 2 lines to the end of the process function defined inside the main function

for obj in iterator:
     pass

... so the process function now looks like this (in spark 1.5.2 at least):

      
     def process():
            iterator = deserializer.load_stream(infile)
            serializer.dump_stream(func(split_index, iterator), outfile)
            for obj in iterator:
                pass

After the change you will need to rebuild your pyspark.zip in the python/lib folder to include the change.

The issue may be that the worker process is completing before the executor has written all the data to it. The thread writing the data down the socket throws an exception and if this happens before the executor marks the task as complete it will cause trouble. The idea is to try to get the worker to pull all the data from the executor even if its not needed to lazily compute the output. This is very inefficient of course so it is a workaround rather than a proper solution.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
引用\[1\]中提到,"Connection reset by peer: socket write error"是一个常见的错误,可能有多种原因。其中一些常见的原因包括服务器的并发连接数超过了其承载量,导致服务器关闭一些连接;客户端关闭了浏览器,但服务器仍在发送数据;或者浏览器按下了停止按钮。这个错误也可能是由于远程主机上的应用程序突然停止运行、远程主机重新启动,或者远程主机在远程套接字上使用了"强制"关闭等原因引起的。此外,如果连接因为"keep-alive"活动检测到失败而中断,也可能导致此错误。\[1\] 引用\[2\]中描述了一个具体的问题,即在一个文件上传接口中,当参数校验失败或者文件已经存在时,客户端会偶尔出现"connection reset by peer, socket write error"的错误。经过猜测和重现,发现只有在上传较大的文件且参数校验失败或者重复上传时才会出现这个错误。作者猜测是因为当客户端上传大文件时,服务端在接收到HTTP头部后开始进行参数校验,并在不符合条件时直接返回响应,关闭输出流的同时也关闭了输入流。通过在服务端改动,先调用request.getInputStream().skip(request.getContentLength)再返回响应,问题得到解决。作者还通过抓包发现,服务端已经返回了错误码信息,但客户端可能没有接收到响应,导致报错。\[2\] 根据引用\[3\]中的说明,HTTP规范只是建议在关闭连接时应该正常关闭传输连接,但没有具体说明如何操作。在关闭连接时,双方应该各自关闭自己的输出信道,并等待对方关闭输出信道,这样连接才能完全关闭,避免出现"connection reset"错误。然而,现实中无法保证双方都按照这个约定操作。因此,除了自己关闭输出信道外,还需要周期性检查输入信道的状态,如果一段时间内对方没有关闭输出信道,就需要强制结束以节省时间。\[3\] 综上所述,"Connection reset by peer: socket write error"错误可能由多种原因引起,包括服务器并发连接数超载、客户端关闭浏览器、浏览器按下停止按钮等。在具体问题中,可能是由于上传较大的文件且参数校验失败或者重复上传导致的。为了解决这个问题,可以在服务端改动,先调用request.getInputStream().skip(request.getContentLength)再返回响应。此外,根据HTTP规范的建议,双方应该各自关闭输出信道,并周期性检查输入信道的状态,以避免"connection reset"错误的发生。 #### 引用[.reference_title] - *1* [Connection reset by peer: socket write error错误分析及解决](https://blog.csdn.net/XingKong22star/article/details/39203611)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [分析connection reset by peer, socket write error错误原因](https://blog.csdn.net/xiaoxiangzi520/article/details/127975743)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值