Created
August 5, 2014 17:14
-
-
Save robinkraft/44706039d4c69473898b to your computer and use it in GitHub Desktop.
precache images for crowdsourcing app
This file contains hidden or 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 sys | |
import requests | |
import multiprocessing | |
URL = 'http://forma-cs-validation.elasticbeanstalk.com/api/alerts/next/cache' | |
def f(a): | |
try: | |
r = requests.get(URL) | |
print r | |
try: | |
x = r.json()['message'] | |
if 'Error: No uncached alerts' in x: | |
sys.exit() | |
except KeyError: | |
return r | |
except requests.exceptions.ConnectionError: | |
print "Connection error" | |
return None | |
if __name__ == '__main__': | |
cpus = multiprocessing.cpu_count() | |
pool = multiprocessing.Pool(processes=cpus) | |
pool.map(f, range(1000000)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment