我试图访问的网页,并检查网站所有者可以联系他或不..线程的内存使用情况不断增加
这里是http://pastebin.com/12rLXQaz
这是函数,每个线程调用:
def getpage():
try:
curl = urls.pop(0)
print "working on " +str(curl)
thepage1 = requests.get(curl).text
global ctot
if "Contact Us" in thepage1:
slist.write("\n" +curl)
ctot = ctot + 1
except:
pass
finally:
if len(urls)>0 :
getpage()
但事实是程序不断得到提高的记忆。(pythonw.exe)
由于线程再次调用函数的合作ndition是真的..程序的内存至少应保持在大致相同的水平。
对于含有100K左右的网址,该方案正在为3GB更和增加列表...
您是否尝试过把它们放入一个'queue.Queue'只有启动100个线程?或者开始最多100个线程,然后开始'join()' – User
还没有尝试Queue ..如果我在函数中使用join,程序将等待所有线程完成,这会花费更多的时间 – user2511798
1.尝试包含相关在你的问题中你的代码的位。 2.你的代码不起作用,“NameError:name'tarray'未定义”。 –