Suds 忽略缓存设置?
我使用的是 suds 0.3.8、Python 2.4.3 和 Django 1.1.1。我继承的代码对缓存文件的持续时间很长,但它会以每 24 小时一次的默认节奏到期。托管模式的外部服务器参差不齐,因此该网站每晚都会崩溃,而我已经束手无策了。
知道这段代码中包含了什么吗?
imp = Import('http://domain2.com/url')
imp.filter.add('http://domain3.com/url')
imp.filter.add('http://domain4.com/url')
imp.filter.add('http://domain5.com/url')
d = ImportDoctor(imp)
url = "http://domain.com/wsdl"
client = Client(url, doctor=d, timeout=30)
clientcache = client.options.cache
clientcache.setduration(days=360)
I'm using suds 0.3.8, Python 2.4.3, and Django 1.1.1. The code I inherited has a long duration for the cached files, but it's expiring on the default cadence of once every 24 hours. The external servers hosting the schemas are spotty, so the site is going down nightly and I'm at the end of my rope.
Any idea what is jacked up in this code?
imp = Import('http://domain2.com/url')
imp.filter.add('http://domain3.com/url')
imp.filter.add('http://domain4.com/url')
imp.filter.add('http://domain5.com/url')
d = ImportDoctor(imp)
url = "http://domain.com/wsdl"
client = Client(url, doctor=d, timeout=30)
clientcache = client.options.cache
clientcache.setduration(days=360)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
该问题可能是 Suds 0.3.8 中的默认缓存类型缺乏适当的支持,甚至可能是该版本中的错误。如果您能够升级到 Suds 0.3.9 或更高版本(最新的是 0.4),那么此行为将按预期工作。
The problem may be a lack of proper support in the default cache type in the Suds 0.3.8, or possibly even a bug in this version. If you're able to upgrade to Suds 0.3.9 or later (latest is 0.4), that would allow this behavior to work as expected.
回答我自己的问题:
这最终不是版本问题,而是用户错误。不幸的是,肥皂水文档并不那么清晰。阅读它,人们会认为上面的代码可以工作,但是(在 suds v0.39+ 上)它应该写成:
现在看,必须在初始化客户端之前配置缓存是完全有道理的。
希望这对尝试设置泡沫缓存的其他人有所帮助,但它似乎忽略了您的设置。
Answering my own question:
This ended up not being a version issue, but user error. Unfortunately the suds documentation isn't as clear as it could be. Reading it, one would think the code above would work, but (on suds v0.39+) it should be written as:
Looking at it now, it makes complete sense that the cache has to be configured before the Client is initialized.
Hopefully this will help anyone else trying to set a suds cache, and it seems to be ignoring your settings.