Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotr-dobrogost/1584694 to your computer and use it in GitHub Desktop.
Save piotr-dobrogost/1584694 to your computer and use it in GitHub Desktop.
learning gevent...
from gevent import monkey
monkey.patch_all()
import gevent
import requests
def http_req(x, url):
r = requests.post(url)
print "Request ", x, r
def http_req2(greenlet):
r = requests.post('http://python-guide.org')
print "Request ", r
if __name__ == '__main__':
greens = [gevent.spawn(http_req, x, 'http://httpbin.org') for x in range(4)]
print "waiting end of greenlets ..."
gevent.joinall(greens)
for green in greens:
green.link(http_req2)
gevent.joinall(greens)
@denik
Copy link

denik commented Jan 10, 2012

try replacing gevent.joinall() with gevent.run()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment