1

当我使用 Requests 库时,使用它的async.map(reqs, size)方法,当reqs是位时,会发生以下错误:

 IOError: zipimport: can not open file /Library/Python/2.7/site-packages/gevent-0.13.6-py2.7-macosx-10.7-intel.egg

但是请求列表很小,那么没问题,有人可以帮我吗?

代码如下:

from requests import async
from time import time
import numpy as np


#urls list
urls = np.loadtxt('data.txt', dtype=str)
#urls = urls[:10]
cnt = 100

#main method
results = []
reqs=[]
def main():
   for i in range(cnt):
       start = time()
       for u in urls:
           reqs.append(async.get(u)) 
       stop = time()
       #print 'cicle %s = %s' %(i, stop-start)
       #results.append(stop-start)
   print len(reqs)
   async.map(reqs, size=100)



if __name__ == '__main__':
   begin = time()
   main()
   end = time()
   print end-begin

它在 时工作正常cnt = 10,但在尝试时出错cnt = 100

4

0 回答 0