Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about ConnectionPool() #226

Closed
doublex opened this issue Sep 20, 2022 · 4 comments
Closed

Question about ConnectionPool() #226

doublex opened this issue Sep 20, 2022 · 4 comments

Comments

@doublex
Copy link

doublex commented Sep 20, 2022

"... please be aware that one session can only be used by one thread at the same time ..."
#206

Does "session" this mean:

  • gclient.net.ConnectionPool() must not be shared among threads
  • a connection from the gclient.net.ConnectionPool() is not shared among threads

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
Copy link
Contributor

wey-gu commented Sep 21, 2022

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

@doublex
Copy link
Author

doublex commented Sep 21, 2022

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
Copy link
Contributor

wey-gu commented Sep 21, 2022

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
Copy link
Author

doublex commented Sep 21, 2022

I see!
Thanks for explanation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants