我有一个正在工作的python程序,它使用sud通过SOAP获取大量数据。web服务是用一个分页函数实现的,这样我就可以在每个fetch调用中获取nnn行,并在随后的调用中获取下一个nnn行。如果我使用如下代码对HTTP服务器进行身份验证
client = suds.client.Client(url=url, location=location, username=username, password=password, timeout=timeout)
一切都很好。但是,如果我使用
t = suds.transport.https.HttpAuthenticated(username=username, password=password) t.handler = urllib2.HTTPBasicAuthHandler(t.pm) t.urlopener = urllib2.build_opener(t.handler) client = suds.client.Client(url=url, location=location, timeout=timeout, transport=t)
它只工作了6次迭代。如果我指定每次取10行的取数限制,则返回60行。第七次取货时,我收到
File "build/bdist.linux-i686/egg/suds/client.py", line 542, in __call__ File "build/bdist.linux-i686/egg/suds/client.py", line 602, in invoke File "build/bdist.linux-i686/egg/suds/client.py", line 649, in send File "build/bdist.linux-i686/egg/suds/client.py", line 698, in failed AttributeError: 'NoneType' object has no attribute 'read'
有人对可能导致这种情况的原因有什么建议吗。肯定是这种变化造成了这个问题。我可以前后交换身份验证样式,它是完全可复制的。
我正在用sud0.4运行python 2.6.6。
谢谢
问题似乎是一个
urllib2.HTTPError
正在从较低的级别提升,其fp
属性为None:suds.transport.http
中的第81行:这个异常最终被传递到
suds.client
中的第698行,其中error.fp.read()
行爆炸:我建议monkey修补
suds.SoapClient
类以获取HTTP错误代码和消息。在构造suds.Client
之前添加这些行,然后运行它以查看第7次提取引发的HTTP错误:相关问题 更多 >
编程相关推荐