You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
kazoo client hangs when I use it within multiprocess.
I'm thinking it's most likely because it's not safe for a child and parent process to share kazoo client.
If that's true, what is the safe way for share a kazoo client within the same process, but still prevent hanging when using multiprocess?
Snippet to Reproduce the Problem
The following code is fine when using single process
client = None
def get_shared_kazoo_client():
""" returns shared kazoo client"""
from kazoo.client import KazooClient
global client
if client is None:
client = KazooClient(hosts=KAZOOCLIENT)
client.start()
return client
def semaphore_function():
client = get_shared_kazoo_client()
throttler = client.Semaphore(max_leases=4, path='/test/path')
with throttler:
logging.info("inside")
if __name__ == '__main__':
semaphore_function()
semaphore_function()
This is fine no matter how many times I call semaphore_function().
However, the following code would hang.
if __name__ == '__main__':
semaphore_function()
p = mp.Process(target=semaphore_function)
p.start()
p.join()
The child process starts, but is unable to ever past with throttler.
I believe this post is observing similar behavior. #519
I would like to have a global shared kazoo client to prevent unnecessarily constructing new kazoo clients over and over again. But, it fails the moment I start multiprocessing.
Any comments would be much appreciated.
Specifications
Kazoo version: 2.6.1
Python version: 3.6
OS: centOS 7
The text was updated successfully, but these errors were encountered:
kazoo client hangs when I use it within multiprocess.
I'm thinking it's most likely because it's not safe for a child and parent process to share kazoo client.
If that's true, what is the safe way for share a kazoo client within the same process, but still prevent hanging when using multiprocess?
Snippet to Reproduce the Problem
The following code is fine when using single process
This is fine no matter how many times I call
semaphore_function()
.However, the following code would hang.
The child process starts, but is unable to ever past
with throttler
.I believe this post is observing similar behavior.
#519
I would like to have a global shared kazoo client to prevent unnecessarily constructing new kazoo clients over and over again. But, it fails the moment I start multiprocessing.
Any comments would be much appreciated.
Specifications
The text was updated successfully, but these errors were encountered: