vesoft-inc / nebula-python

Client API of Nebula Graph in Python
194 stars 76 forks source link

Question about ConnectionPool() #226

Closed doublex closed 1 year ago

doublex commented 1 year ago

"... please be aware that one session can only be used by one thread at the same time ..." https://github.com/vesoft-inc/nebula-python/issues/206

Does "session" this mean:

More precise, is this allowed?

global connection_pool = gclient.net.ConnectionPool()

def thread_1():
    global connection_pool
    ...

def thread_2():
    global connection_pool
    ...
wey-gu commented 1 year ago

Yes, it isn't thread-safe, thus we should maintain a local connection pool per thread :).

doublex commented 1 year ago

Dear @wey-gu If I create a connection-pool with e.g. 30 connections. How can a thread query 30 GO-statements in parallel? Best wishes from Vienna!

wey-gu commented 1 year ago

Dear @wey-gu If I create a connection-pool with e.g. 30 connections. How can a thread query 30 GO-statements in parallel? Best wishes from Vienna!

Yes, you can, just ensure one session can only be used by one thread is enough.

doublex commented 1 year ago

I see! Thanks for explanation!