A threading based handler.
The SequentialThreadingHandler is intended for regular Python environments that use threads.
- class kazoo.handlers.threading.SequentialThreadingHandler¶
Threading handler for sequentially executing callbacks.
This handler executes callbacks in a sequential manner. A queue is created for each of the callback events, so that each type of event has its callback type run sequentially. These are split into two queues, one for watch events and one for async result completion callbacks.
Each queue type has a thread worker that pulls the callback event off the queue and runs it in the order the client sees it.
This split helps ensure that watch callbacks won’t block session re-establishment should the connection be lost during a Zookeeper client call.
Watch and completion callbacks should avoid blocking behavior as the next callback of that type won’t be run until it completes. If you need to block, spawn a new thread and return immediately so callbacks can proceed.
Completion callbacks can block to wait on Zookeeper calls, but no other completion callbacks will execute until the callback returns.
Dispatch to the callback object
The callback is put on separate queues to run depending on the type as documented for the SequentialThreadingHandler.
Create an appropriate Event object
Create a lock object
alias of Empty
alias of Queue
Create an appropriate RLock object
Delay execution for a given number of seconds. The argument may be a floating point number for subsecond precision.
Start the worker threads.
Stop the worker threads and empty all queues.