Created
October 24, 2017 22:27
-
-
Save harlowja/7abc0d60296fd881bb4817bb0a72289b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import contextlib | |
import os | |
import socket | |
import time | |
from kazoo import client | |
def do_hello(): | |
print("Hello from %s:%s" % (socket.gethostname(), os.getpid())) | |
while True: | |
time.sleep(5) | |
def main(): | |
k_client = client.KazooClient(hosts=os.environ['ZOOKEEPER_HOSTS']) | |
k_client.start() | |
with contextlib.closing(k_client): | |
e = k_client.Election("/hello") | |
e.run(do_hello) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment