-
Notifications
You must be signed in to change notification settings - Fork 80
Description
from nebula3.gclient.net import ConnectionPool
from nebula3.Config import Config
define a config
config = Config()
config.max_connection_pool_size = 10
init connection pool
connection_pool = ConnectionPool()
if the given servers are ok, return true, else return false
ok = connection_pool.init([('127.0.0.1', 9669)], config)
option 1 control the connection release yourself
get session from the pool
session = connection_pool.get_session('root', 'nebula')
select space
session.execute('USE basketballplayer')
show tags
result = session.execute('SHOW TAGS')
print(result)
release session
session.release()
option 2 with session_context, session will be released automatically
with connection_pool.session_context('root', 'nebula') as session:
session.execute('USE basketballplayer')
result = session.execute('SHOW TAGS')
print(result)
close the pool
connection_pool.close()
在使用官方案例时会报错
Connect 10.113.36.125:9669 failed: Socket read failed: [Errno 104] Connection reset by peer
Traceback (most recent call last):
File "/home/chatgpt/m31660/Pycharm/nebula/insert_gcov_data.py", line 148, in
nebula_pool = create_nebula_root_client()
File "/home/chatgpt/m31660/Pycharm/nebula/insert_gcov_data.py", line 64, in create_nebula_root_client
success = connection_pool.init([('10.113.36.125', 9669)], config)
File "/home/chatgpt/.local/lib/python3.10/site-packages/nebula3/gclient/net/ConnectionPool.py", line 83, in init
raise RuntimeError(
RuntimeError: The services status exception: [services: ('10.113.36.125', 9669), status: BAD]
必须要重启nebula才可以运行的通。请问有人知道这是什么问题吗?