-
Notifications
You must be signed in to change notification settings - Fork 387
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
KazooClient thread-safety and instance reuse #728
Comments
Hi,
It can safely be used across multiple threads, but do *not* use it across
processes (forks).
Cheers,
…On Wed, Sep 6, 2023, 10:37 Jan Van den bosch ***@***.***> wrote:
I couldn't immediately find an answer in the docs re: thread-safety and
reuse of KazooClient.
I would like to know if an instance of KazooClient is supposed to be
short-lived and limited to a single thread or if a shared instance can be
used from multiple threads.
In particular, is there any problem with:
1. instantiate + start() a single instance of KazooClient at the
startup of a web application and reusing it everywhere;
2. stop() and close() said instance at shutdown?
Thanks!
—
Reply to this email directly, view it on GitHub
<#728>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIFTHW7WQJGDOH3IXGPXV3XZCDEFANCNFSM6AAAAAA4NOM42E>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Thanks. So would you recommend using a single |
None, we have been doing single kazoo client shared by multiple threads for
years now.
Only advice is make sure you run a little code on the watchers' thread as
possible (there is only one per KazooClient) since it will be shared.
Create a worker thread and pass it all the events for processing using a
queue.Queue.
Cheers,
…On Wed, Sep 6, 2023, 11:19 Jan Van den bosch ***@***.***> wrote:
Thanks. So would you recommend using a single KazooClient instance across
the entire application? Are there any drawbacks, considerations?
—
Reply to this email directly, view it on GitHub
<#728 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIFTHS4WPODHYISAQJYRE3XZCIBNANCNFSM6AAAAAA4NOM42E>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
That's clear, thanks. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I couldn't immediately find an answer in the docs re: thread-safety and reuse of
KazooClient
.I would like to know if an instance of
KazooClient
is supposed to be short-lived and limited to a single thread or if a shared instance can be used from multiple threads.In particular, is there any problem with:
start()
a single instance ofKazooClient
at the startup of a web application and reusing it everywhere;stop()
andclose()
said instance at shutdown?Thanks!
The text was updated successfully, but these errors were encountered: