#!/usr/bin/env python import pycurl, StringIO, pdb cobj1 = pycurl.Curl() cobj2 = pycurl.Curl() cobj3 = pycurl.Curl() cobj4 = pycurl.Curl() cobj1.setopt(pycurl.URL, "http://www.eglug.org") cobj1.setopt(pycurl.URL, "http://www.linux-egypt.org") cobj1.setopt(pycurl.URL, "http://www.kernel.org") cobj1.setopt(pycurl.URL, "http://www.parismfn.org") str1 = StringIO.StringIO() str2 = StringIO.StringIO() str3 = StringIO.StringIO() str4 = StringIO.StringIO() cobj1.setopt(pycurl.WRITEFUNCTION, str1.write) cobj2.setopt(pycurl.WRITEFUNCTION, str2.write) cobj3.setopt(pycurl.WRITEFUNCTION, str3.write) cobj4.setopt(pycurl.WRITEFUNCTION, str4.write) multi1 = pycurl.CurlMulti() multi1.add_handle(cobj1) multi1.add_handle(cobj2) multi1.add_handle(cobj3) multi1.add_handle(cobj4) while 1: ret, num_handles = multi1.perform() if ret != pycurl.E_CALL_MULTI_PERFORM: break while num_handles: ret = multi1.select(1.0) if ret == -1: continue while 1: ret, num_handles = multi1.perform() if ret != pycurl.E_CALL_MULTI_PERFORM: break print len(str1.getvalue()), len(str2.getvalue()), len(str3.getvalue()), len(str4.getvalue())