Skip to content

Instantly share code, notes, and snippets.

@gparuthi
Last active August 29, 2015 14:00
Show Gist options
  • Save gparuthi/11183609 to your computer and use it in GitHub Desktop.
Save gparuthi/11183609 to your computer and use it in GitHub Desktop.
Python Utilities
# Publish progress to redis
# publish the status of a long running parallel from ipy cluster process to a redis server
# a webservice can then read this and feed it to a javascript visualization
def pub_to_redis(pres, title):
import Redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
n = len(pres)
p = ProgressBar.ProgressBar(n)
while True:
c = pres.progress
r.set(title+':c',c)
r.set(title+':n',n)
p.animate(c)
time.sleep(5)
pres = lview.map_async(func, list_of_elements)
pub_to_redis(pres, 'kiva_get_lender_teams')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment