【发布时间】:2017-10-10 09:28:04
【问题描述】:
我正在使用 tornado python 执行对外部代理服务的数百次非阻塞调用。 外部代理服务要求我在每次通话时都使用新连接。
我写了以下内容:
config = {
'proxy_host': 'host',
'proxy_port': port
}
httpclient.AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
for url in urls:
client = httpclient.AsyncHTTPClient(force_instance=True)
client.fetch(url, callback=callback, headers=headers, **config)
ioloop.IOLoop.instance().start()
def handle_request()
do_something()
if io_counter == max_calls:
ioloop.IOLoop.instance().stop()
但是,该服务声称我使用的是相同的连接。
如何在每次通话中使用不同的连接?
【问题讨论】:
-
每个请求都是使用不同的套接字发出的,因此每个请求实际上是不同的连接。也许代理服务要求您使用不同的 IP 地址发出请求?
-
不,他们没有。因为这是他们的服务——他们需要提供一个轮换代理 ID。在这种情况下我需要 force_instance=True 吗?
-
我不能说。这个问题可能会有所帮助 - stackoverflow.com/q/21499722/1925257
-
谢谢。将看到如何从这里开始
标签: python python-2.7 proxy tornado