2 # -*- coding: iso-8859-1 -*-
6 import sys, select, time
12 c1.setopt(c1.URL, "http://www.python.org")
13 c2.setopt(c2.URL, "http://curl.haxx.se")
14 c3.setopt(c3.URL, "http://slashdot.org")
15 c1.body = open("doc1", "wb")
16 c2.body = open("doc2", "wb")
17 c3.body = open("doc3", "wb")
18 c1.setopt(c1.WRITEFUNCTION, c1.body.write)
19 c2.setopt(c2.WRITEFUNCTION, c2.body.write)
20 c3.setopt(c3.WRITEFUNCTION, c3.body.write)
22 m = pycurl.CurlMulti()
27 # Number of seconds to wait for a timeout to happen
30 # Stir the state machine into action
32 ret, num_handles = m.perform()
33 if ret != pycurl.E_CALL_MULTI_PERFORM:
36 # Keep going until all the connections have terminated
38 # The select method uses fdset internally to determine which file descriptors
40 m.select(SELECT_TIMEOUT)
42 ret, num_handles = m.perform()
43 # Print the message, if any
45 if ret != pycurl.E_CALL_MULTI_PERFORM:
59 print "http://www.python.org is in file doc1"
60 print "http://curl.haxx.se is in file doc2"
61 print "http://slashdot.org is in file doc3"