Skip to content

Instantly share code, notes, and snippets.

@mgadzhi
Created May 14, 2015 11:01
Show Gist options
  • Save mgadzhi/4e14ed7ba5ccd19f1f12 to your computer and use it in GitHub Desktop.
Save mgadzhi/4e14ed7ba5ccd19f1f12 to your computer and use it in GitHub Desktop.
curlMulti example
#!/usr/bin/env python
import pycurl
import select
def write(*args):
pass
if __name__ == '__main__':
cs = [pycurl.Curl() for x in xrange(300)]
m = pycurl.CurlMulti()
for h in cs:
h.setopt(pycurl.URL, 'http://google.com')
h.setopt(pycurl.WRITEFUNCTION, write)
m.add_handle(h)
while 1:
ret, num_handles = m.perform()
if ret != pycurl.E_CALL_MULTI_PERFORM:
break
while num_handles:
apply(select.select, m.fdset() + (1,))
while 1:
ret, num_handles = m.perform()
if ret != pycurl.E_CALL_MULTI_PERFORM:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment