Candygram

S

Salvatore

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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top