python3.9连接2.0报错'ConfigParser' object has no attribute 'idle_time'

提问参考模版:

  • nebula 版本:2.0
  • 部署方式 :单机
  • 问题的具体描述
  • 相关的 meta / storage / graph info 日志信息
def nebula_session(func):
    @wraps(func)
    def wrapped_function(*args,**kwargs):
        # define a config
         nebula_config = Config()
         nebula_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([(nebula_addr, nebula_port)], config)

         with connection_pool.session_context(nebula_user, nebula_password) as session:
             session.execute('USE tyc2021')
             func(session,*args,**kwargs)
         connection_pool.close()

     return wrapped_function

之后,用这个装饰器

@nebula_session
def main(session,argv):
    result = session.execute('SHOW TAGS')
   print(result)

报错

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/Cellar/python@3.9/3.9.2_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/wangli/App/scrap_tyc2021/src/client_ready_data_for_nebula_import/__main__.py", line 39, in <module>
    main(sys.argv)
  File "/Users/wangli/App/scrap_tyc2021/src/nebula/__init__.py", line 30, in wrapped_function
    ok = connection_pool.init([(nebula_addr, nebula_port)], config)
  File "/Users/wangli/App/scrap_tyc2021/venv39/lib/python3.9/site-packages/nebula2/gclient/net/__init__.py", line 150, in init
    self._period_detect()
  File "/Users/wangli/App/scrap_tyc2021/venv39/lib/python3.9/site-packages/nebula2/gclient/net/__init__.py", line 318, in _period_detect
    self._remove_idle_unusable_connection()
  File "/Users/wangli/App/scrap_tyc2021/venv39/lib/python3.9/site-packages/nebula2/gclient/net/__init__.py", line 301, in _remove_idle_unusable_connection
    if self._configs.idle_time == 0:
AttributeError: 'ConfigParser' object has no attribute 'idle_time'

你用的是什么版本的客户端,代码行数对不上。还有 ConfigParser 这个object从哪来的,你代码里面没有它,但是传给池用的是这个object,你是不是传错对象了

1 个赞

找到原因了,是config的问题,写错了。
但是这个问题处理之后,还是不行,又出问题
AttributeError: ‘ConnectionPool’ object has no attribute ‘session_context’

from nebula2.gclient.net import ConnectionPool
这个是支持nebula2吗

pip install nebula2-python==2.0.0之后好了