doc: update heartbeat doc to use start_heart=True
Change-Id: I5560b1ec1da7922586e5544d55b5e508c70a33fc
This commit is contained in:
parent
5946fef119
commit
ba62597183
@ -26,16 +26,16 @@ identifying the running program.
|
|||||||
After the coordinator is created, it can be used to use the various features
|
After the coordinator is created, it can be used to use the various features
|
||||||
provided.
|
provided.
|
||||||
|
|
||||||
In order to keep the connection to the coordination server active, you must
|
In order to keep the connection to the coordination server active, the method
|
||||||
call regularly the :meth:`~tooz.coordination.CoordinationDriver.heartbeat`
|
:meth:`~tooz.coordination.CoordinationDriver.heartbeat` method must be called
|
||||||
method. This will ensure that the coordinator is not considered dead by
|
regularly. This will ensure that the coordinator is not considered dead by
|
||||||
other program participating in the coordination.
|
other program participating in the coordination. Unless you want to call it
|
||||||
|
manually, you can use tooz builtin heartbeat manager by passing the
|
||||||
|
`start_heart` argument.
|
||||||
|
|
||||||
.. literalinclude:: ../../../examples/coordinator_heartbeat.py
|
.. literalinclude:: ../../../examples/coordinator_heartbeat.py
|
||||||
:language: python
|
:language: python
|
||||||
|
|
||||||
We use a pretty simple mechanism in this example to send a heartbeat every
|
|
||||||
once in a while, but depending on your application, you may want to send the
|
|
||||||
heartbeat at different moment or intervals.
|
heartbeat at different moment or intervals.
|
||||||
|
|
||||||
Note that certain drivers, such as `memcached` are heavily based on timeout,
|
Note that certain drivers, such as `memcached` are heavily based on timeout,
|
||||||
|
@ -1,15 +1,5 @@
|
|||||||
import time
|
|
||||||
|
|
||||||
from tooz import coordination
|
from tooz import coordination
|
||||||
|
|
||||||
ALIVE_TIME = 5
|
|
||||||
|
|
||||||
coordinator = coordination.get_coordinator('zake://', b'host-1')
|
coordinator = coordination.get_coordinator('zake://', b'host-1')
|
||||||
coordinator.start()
|
coordinator.start(start_heart=True)
|
||||||
|
|
||||||
start = time.time()
|
|
||||||
while time.time() - start < ALIVE_TIME:
|
|
||||||
coordinator.heartbeat()
|
|
||||||
time.sleep(0.1)
|
|
||||||
|
|
||||||
coordinator.stop()
|
coordinator.stop()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user