Python索引器:从空列表中弹出

Python索引器:从空列表中弹出,python,proxy,python-multithreading,Python,Proxy,Python Multithreading,这是脚本中使用.pop的部分,列表肯定不是空的。。它是wierd,如果在1000个代理下,它会抛出错误,所以我将1000个代理复制到2000个,然后它运行,但是一旦它使用了这么多代理,那么抛出的错误列表是空的?如果不是,我想循环我的代理,但主要问题是它应该从第一个代理到最后一个代理,并完成任务 相反,它声称列表是空的,带有 索引器:从空列表中弹出。您是否可以在调用pop之前打印或记录self.servers,以便我们可以查看其中包含的内容?您有两个来自self.proxy的弹出窗口,而无需在其中

这是脚本中使用.pop的部分,列表肯定不是空的。。它是wierd,如果在1000个代理下,它会抛出错误,所以我将1000个代理复制到2000个,然后它运行,但是一旦它使用了这么多代理,那么抛出的错误列表是空的?如果不是,我想循环我的代理,但主要问题是它应该从第一个代理到最后一个代理,并完成任务

相反,它声称列表是空的,带有


索引器:从空列表中弹出。

您是否可以在调用
pop
之前打印或记录
self.servers
,以便我们可以查看其中包含的内容?您有两个来自
self.proxy
的弹出窗口,而无需在其中检查是否为空。看起来它偶尔会是空的。注意:它不是
ip=line.split(':')[0]
port=line.split(':')[1]
您可以执行
ip,port=line.split(':')[0:2]
@SuperBiasedMan,它只输出服务器是否处于活动状态,所以如果服务器处于活动状态,如果服务器死了打印'dead'@LucyBeale,我的意思是
print(repr(self.servers))
以找出其中实际存储的内容。如果一个字符串存储在那里,您将得到一个不同的错误,因此它不能是包含
“active”
“dead”
def check_proxy(self, proxy):
    urllib2.install_opener(
        urllib2.build_opener(
            urllib2.ProxyHandler({'https': 'http://%s' % proxy})
            )
        )

    try:
        urllib2.urlopen(self.proxy_test_url, timeout=self.proxy_timeout)
        return True
    except:
        return False

def run(self):
    switch = False
    while self.servers and self.proxies:
        self.cron['servers_left'] = len(self.servers)
        self.cron['proxies_left'] = len(self.proxies)

        line = self.servers.pop(0)
        ip = line.split(':')[0]
        port = line.split(':')[1]

        if not 'proxy' in locals() or switch == True:
            proxy = self.proxies.pop(0)

        if not self.check_proxy(proxy):
            proxy = self.proxies.pop(0)
            continue

        switch = False

        if self.check(ip, port, proxy) == False:
            self.server.insert(0,line)
            switch = True


c = checker(inn, valid, server, proxies)
for t in range(thread_count):
    threads.append(my_thread(c))

print 'Starting threads 1 - %s.' % str(thread_count)

for t in threads:
    t.start()
    time.sleep(0.1)