py2neo: py2neo.packages.httpstream.http.SocketError: timed out - execute, stream or Transactions?

py2neo: py2neo.packages.httpstream.http.SocketError: timed out - execute, stream or Transactions?

首先。如果这不是同谋结构,我很抱歉。我只是不确定从哪里开始或结束,但我已尽力为您提供尽可能多的信息。

我在 AWS M3.large、py2neo 2.0.4 和 neo4j-community-2.1.7

上工作

我正在尝试使用 py2neo 将大型数据集导入到 neo4j 中。我的问题是,当我阅读大约 150k 时,它只给我一个:py2neo.packages.httpstream.http.SocketError: timed out

我需要增加数百万的输入,所以 150k 应该就可以了。

整个错误:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/py2neo/packages/httpstream/http.py", line 322, in submit
    response = send()
  File "/usr/local/lib/python3.4/dist-packages/py2neo/packages/httpstream/http.py", line 318, in send
    return http.getresponse(**getresponse_args)
  File "/usr/lib/python3.4/http/client.py", line 1147, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/py2neo/packages/httpstream/http.py", line 331, in submit
    response = send("timeout")
  File "/usr/local/lib/python3.4/dist-packages/py2neo/packages/httpstream/http.py", line 318, in send
    return http.getresponse(**getresponse_args)
  File "/usr/lib/python3.4/http/client.py", line 1147, in getresponse
    response.begin()
  File "/usr/lib/python3.4/http/client.py", line 351, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.4/http/client.py", line 313, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/lib/python3.4/socket.py", line 371, in readinto
    return self._sock.recv_into(b)
socket.timeout: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "transactions.py", line 221, in <module>
    read_zip("data")
  File "transactions.py", line 44, in read_zip
    create_tweets(lines)
  File "transactions.py", line 215, in create_tweets
    tx.process()
  File "/usr/local/lib/python3.4/dist-packages/py2neo/cypher/core.py", line 296, in process
    return self.post(self.__execute or self.__begin)
  File "/usr/local/lib/python3.4/dist-packages/py2neo/cypher/core.py", line 248, in post
    rs = resource.post({"statements": self.statements})
  File "/usr/local/lib/python3.4/dist-packages/py2neo/core.py", line 322, in post
    response = self.__base.post(body, headers, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/py2neo/packages/httpstream/http.py", line 984, in post
    return rq.submit(**kwargs)
  File "/usr/local/lib/python3.4/dist-packages/py2neo/packages/httpstream/http.py", line 433, in submit
    http, rs = submit(self.method, uri, self.body, self.headers)
  File "/usr/local/lib/python3.4/dist-packages/py2neo/packages/httpstream/http.py", line 362, in submit
    raise SocketError(code, description, host_port=uri.host_port)
py2neo.packages.httpstream.http.SocketError: timed out

现在我用的是cypher。我分批写入 ~1000,但较小的批次也不起作用。我的问题是,我可以使用其他方法让它更快吗?

现在,我这样做:

stagement = "match (p:person {id=123}) ON CREATE SET p.age = 132" 

def add_names(names):
    for-loop with batches of 1000:
        tx = graph.cypher.begin()

        for name in names:
            tx.append(statement, {"N": name})
        tx.process()

    tx.commit()

但是使用 execute 或 stream 或其他任何我可以做的事情会更好吗?

有用link:

尝试添加

from py2neo.packages.httpstream import http http.socket_timeout = 9999