【问题标题】:Error message: Protocol wrong type for socket with py2neo错误消息:带有 py2neo 的套接字的协议类型错误
【发布时间】:2015-06-04 20:48:57
【问题描述】:

我正在使用 py2neo 从 neo4j 图形数据库中查询一组数据,并在 python 脚本中获得适当信息后创建节点之间的关系。

这是脚本的基本结构。

import py2neo

### get a set of data from a graph database  
graph = Graph()
query =  graph.cypher.execute("MATCH (p:LABEL1))-[:relationship]->(c:Label2 {Name:'property'} \
 RETURN p.Id, p.value1, c.value2 LIMIT 100")

### do a data analysis within a python script here
~ ~ ~ 

### update newly found information through the analysis to the graph database

tx = graph.cypher.begin()
qs1 = "UNWIND range(0,{size}-1) AS r \ 
       MATCH (p1:Label1 {Id:{xxxx}[r]}),(p2:Label2 {Id:{yyyy}[r]}) \
       MERGE (p1)-[:relationship {property:{value}[r]]->(p2)"
tx.append(qs1, parameters = {"size":size, \ 
                             "xxxx":xxxx, \
                             "yyyy":yyyy, \
                             "value":value})
tx.commit()

当查询结果限制为100时,脚本确实按预期执行,但是当我增加200或以上时,程序崩溃,并留下以下错误消息:

--> 263 tx.commit()

SocketError: 套接字的协议类型错误

不幸的是,除了上面的陈述,没有其他有用的信息可以暗示问题可能是什么。有没有人遇到过这种问题,您能否提出潜在的问题可能是什么?

谢谢。

【问题讨论】:

    标签: python sockets neo4j py2neo


    【解决方案1】:

    我没有深入研究这个问题。 我在使用时遇到了同样的错误:

    tx = graph.cypher.begin()
    tx.append("my cypher statement, i.e. MATCH STUFF")
    tx.process()
    ....
    tx.commit()
    

    我在每个 process 调用之间添加了 1000 条语句,而每 2000 条语句我将添加 commit。 当我将进程和提交之间的语句数量减少到 250/500 时,它可以正常工作(类似于您限制为 100)。

    堆栈跟踪中的实际错误来自python的http/client:

    File "/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/lib/python3.4/http/client.py", line 888, in send
    self.sock.sendall(data)
    OSError: [Errno 41] Protocol wrong type for socket
    

    这是 EPROTOTYPE 错误,所以它发生在客户端而不是 neo4j 中。

    你在 OS X 上吗? (我是。)这看起来可能是问题所在: Chasing an EPROTOTYPE Through Rust, Sendto, and the OSX Kernel With C-Reduce。我对底层套接字行为知之甚少,无法告诉您为什么减少我们通过连接发送的数量会消除竞争条件。

    【讨论】:

      猜你喜欢
      • 2020-05-11
      • 1970-01-01
      • 2014-07-11
      • 1970-01-01
      • 2022-12-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-04
      相关资源
      最近更新 更多