python-zk/kazoo

KazooClient thread-safety and instance reuse

bossie opened this issue · 4 comments

bossie commented

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!

ceache commented
bossie commented

Thanks. So would you recommend using a single KazooClient instance across the entire application? Are there any drawbacks, considerations?

ceache commented
bossie commented

That's clear, thanks.