Skip to content

Instantly share code, notes, and snippets.

@tylertreat
Created December 31, 2014 20:51
Show Gist options
  • Save tylertreat/7851d763d99fb404100d to your computer and use it in GitHub Desktop.
Save tylertreat/7851d763d99fb404100d to your computer and use it in GitHub Desktop.
import os
import time
from service_discovery import ServiceDiscovery
DEFAULT_PORT = 5555
DEFAULT_DEADLINE = 5000
DEFAULT_INTERVAL = 2000
def start_discovery(port, deadline, interval):
discovery = ServiceDiscovery(port, deadline=deadline)
discovery.bind()
print 'Starting service discovery [port: %s, deadline: %s, interval: %s]' \
% (port, deadline, interval)
while True:
print discovery.discover()
time.sleep(interval / 1000)
if __name__ == '__main__':
port = int(os.environ.get('PORT', DEFAULT_PORT))
deadline = int(os.environ.get('DEADLINE', DEFAULT_DEADLINE))
interval = int(os.environ.get('INTERVAL', DEFAULT_INTERVAL))
start_discovery(port, deadline, interval)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment