Suds does not reuse cached WSDL and XSD, although I expect it to

I am sure suds does not cache my WSDL and XSD as I expect . Here, as I know, cached objects are not used:

  • It takes about 30 seconds to create a client: client = Client(url)
  • Recorder records show sequential digesting of XSD and WSDL files within 30 seconds.
  • Wireshark shows consistent TCP traffic on a server that stores XSD and WSDL files for 30 seconds.
  • I see that the files in the cache are updated every time I run my program

I have a small program that creates a suds client, sends one request, receives a response, and ends. I expect that every time I run the program, it should extract the WSDL and XSD files from the file cache, and not from the URLs. This is why I think that:

  • client.options.cache.duration - ('days', 1)
  • client.options.cache.location set to c:\docume~1\mlin\locals~1\temp\suds , and I see that cache files are generated and generated each time the program starts
  • For a moment, I thought that maybe the cache is not reused between runs of the program, but I don’t think the cache file will be used if it is, because the cache in memory will be just fine

I don’t understand how foam caching should work?

+6
source share
1 answer

The problem is with the suds library itself. In cache.py, although ObjectCache.get() always gets a valid file pointer, it removes the exception (EOFError) that executes pickle.load(fp) . When this happens, the file will download again.

Here's the sequence of events:

DocumentReader.open ():

Therefore, it does not matter that the new cache file has been saved, because the same thing happens the next time you start. This happens for ALL WSDL and XSD files.

I fixed this problem by opening the cache file in binary mode while reading and writing. In particular, 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 code well enough to know if these changes are safe, but it pulls objects from the file cache, the service still works successfully, and the client download went from 16 seconds down to 2.5 seconds . Much better if you ask me.

We hope that this correction or something similar can be introduced back into the main line of foam. I already sent this to the foam mailing list (fedora-suds-list in redhat dot com).

+15
source

Source: https://habr.com/ru/post/888371/


All Articles