Candygram

Salvatore salvatore.didio at wanadoo.fr
Tue Aug 29 03:32:11 EDT 2006


Hello,

I am using the following code to fetch URL
Is there a way to speed it. I cant't get rid of the time.sleep(1) for
every request !!!
Thank you for you advise

Regards

Salvatore


from candygram import cg

def fetchURL():
    r = cg.Receiver()
    r.addHandler(cg.Any,getURL,cg.Message)
    for message in r:
            item.append(message)

def getURL(name):
    url = DServeur[name]['urladmin']
    try:
        s = urllib2.urlopen(url)
    except:
            return "\n%s : HS"%name
    return "URL :%s"%name,s.read()[1:10]


socket.setdefaulttimeout(1)
serveurs = DServeur.keys()
serveurs.sort()
def go():
    proc = cg.spawn(fetchURL)
    for s in serveurs:
        proc.send(s)
        time.sleep(1)    #How can I speed up this code ?

go()




More information about the Python-list mailing list