Skip to content

Instantly share code, notes, and snippets.

@andrefsp
Last active February 9, 2016 23:36
Show Gist options
  • Save andrefsp/e6115b6de50de00eba1d to your computer and use it in GitHub Desktop.
Save andrefsp/e6115b6de50de00eba1d to your computer and use it in GitHub Desktop.
Gevent non blocking socket
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