Skip to content

Instantly share code, notes, and snippets.

@davidbirdsong
Created October 27, 2015 19:43
Show Gist options
  • Save davidbirdsong/6a74597f7feb31f411ff to your computer and use it in GitHub Desktop.
Save davidbirdsong/6a74597f7feb31f411ff to your computer and use it in GitHub Desktop.
vanilla.consul fd leak
import vanilla, vanilla.consul
import consul
c = consul.Consul()
_, d = c.health.service('mogtracker', passing=1)
for row in d:
print '%s:%d' % (row['Node']['Address'], row['Service']['Port'])
h = vanilla.Hub()
def Changes(h, service):
sender, recver = h.pipe()
@h.spawn
def _():
c = h.consul()
index = None
while True:
index, nodes = c.health.service(service, index=index).recv()
sender.send(nodes)
return recver
for changes in Changes(h, 'hwy-store'):
print changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment