Suds is not reusing cached WSDLs and XSDs, although I expect it to

北城以北 提交于 2019-11-27 14:50:28

The problem is in the suds library itself. In cache.py, although ObjectCache.get() is always getting a valid file pointer, it's hitting an exception (EOFError) doing pickle.load(fp). When that happens, the file is just downloaded again.

Here's the sequence of events:

DocumentReader.open():

  1. Trying http://172.28.50.249/wsdl/billingServices/v3.0/RequestScrubAddress.wsdl
  2. Loading ObjectCache 51012453-document
  3. Loading pickled object...
  4. Exception raised:
  5. Got None from cache
  6. Downloading... Done
  7. Saving FileCache 51012453-document... Done

So it doesn't really matter that the new cache file was saved, because the same thing happens the next time I run. This happens for ALL of WSDL and XSD files.

I fixed that problem by opening the cache file in binary mode when reading and writing. Specifically, the changes I made were in cache.py:

1) In FileCache.put(), change this line:

f = self.open(fn, 'w')

to

f = self.open(fn, 'wb')

2) In FileCache.getf(), change this line:

return self.open(fn)

to

return self.open(fn, 'rb')

I don't know the codebase well enough to know if these changes are safe, but it is pulling the objects from the file cache, the service is still running successfully, and loading the client went from 16 seconds down to 2.5 seconds. Much better if you ask me.

Hopefully this fix, or something similar can be introduced back into the suds main line. I've already sent this to the suds mailing list (fedora-suds-list at redhat dot com).

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!