-
版本信息:
Python: 3.11.0
Nebula: 3.6.0
nebula3-python: 3.4.0 -
异常信息:
➜ neo4j-benchmark git:(main) ✗ /usr/local/bin/python3 /Users/yicyao/python-projects/neo4j-benchmark/nebula_client.py
ResultSet(...); cost time: 274.40810203552246
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/fbthrift/transport/TSocket.py", line 305, in read
buff = self.handle.recv(sz)
^^^^^^^^^^^^^^^^^^^^
TimeoutError: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/gclient/net/Connection.py", line 148, in execute_parameter
resp = self._connection.executeWithParameter(session_id, stmt, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/graph/GraphService.py", line 1652, in executeWithParameter
return self.recv_executeWithParameter()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/graph/GraphService.py", line 1665, in recv_executeWithParameter
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/fbthrift/protocol/THeaderProtocol.py", line 157, in readMessageBegin
self.trans._reset_protocol()
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/fbthrift/transport/THeaderTransport.py", line 238, in _reset_protocol
self.readFrame(0)
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/fbthrift/transport/THeaderTransport.py", line 268, in readFrame
word1 = self.getTransport().readAll(4)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/fbthrift/transport/TTransport.py", line 72, in readAll
chunk = self.read(need)
^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/fbthrift/transport/TTransport.py", line 183, in read
self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/fbthrift/transport/TSocket.py", line 310, in read
raise TTransportException(
nebula3.fbthrift.transport.TTransport.TTransportException: Socket read failed: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/yicyao/python-projects/neo4j-benchmark/nebula_client.py", line 25, in <module>
execute_query(query)
File "/Users/yicyao/python-projects/neo4j-benchmark/nebula_client.py", line 17, in execute_query
result = session.execute(query)
^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/gclient/net/Session.py", line 77, in execute
return self.execute_parameter(stmt, None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/gclient/net/Session.py", line 42, in execute_parameter
resp = self._connection.execute_parameter(self._session_id, stmt, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/nebula3/gclient/net/Connection.py", line 154, in execute_parameter
raise IOErrorException(IOErrorException.E_TIMEOUT, te.message)
nebula3.Exception.IOErrorException: Socket read failed: timed out
Closing a connection that is in use
- 代码详情
from nebula3.Config import Config
from nebula3.gclient.net.SessionPool import SessionPool
from nebula3.gclient.net import ConnectionPool
import time
import numpy as np
config = Config()
config.timeout = 100000
config.max_connection_pool_size = 10
connection_pool = ConnectionPool()
ok = connection_pool.init([('...', 9669)], config)
session = connection_pool.get_session('root', 'nebula')
session.execute('USE dataset_1')
def execute_query(query):
start_time = time.time()
result = session.execute(query)
print(result)
end_time = time.time()
print("{} cost time: {}".format(query, float(end_time - start_time) * 1000.0))
size = 2
for i in range(size):
query = "..."
execute_query(query)
其他信息:
- nebula 通过 docker-compose 部署在一台服务器上面,默认配置。