Last active
February 9, 2016 23:36
-
-
Save andrefsp/e6115b6de50de00eba1d to your computer and use it in GitHub Desktop.
Gevent non blocking socket
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 gevent | |
from gevent import monkey | |
monkey.patch_all() | |
import requests | |
def fetch_request(url): | |
print("fetching %s" % url) | |
requests.get(url) | |
print("Finish fetching %s" % url) | |
jobs = [] | |
for url in ("http://google.com", "http://facebook.com"): | |
jobs.append(gevent.spawn(fetch_request, url)) | |
gevent.joinall(jobs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment