pythoncachingsoapsuds

Completely disable SUDS schema caching


My webserver needs to request data from remote SOAP service. This happens very rarely so I don't want to have any caching. In fact, the SOAP provider sometimes changes schema and adds new parameters to it - so I have to download and parse the whole schema each time.

I am using this code:

url = 'http://someurl'
cli = suds.client.Client(url)
cli.set_options(cache=None)
return cli

but this still have caching. And the temp data in /tmp/suds is created. How do I completely disable suds caching?

Will changing cli.set_options to .Client(url, cache=None) fix the problem? Sorry, I have no ability to test this myself at the moment.


Solution

  • First of all this is a bit hard to answer definitively because there are multiple versions and forks of suds floating around. Currently the version from fedorahosted looks unmaintained but I've seen other forks being pretty active (in comparison).

    Setting the cache options in the constructor seems to be better because the Client instantiates some other classes and passes the caching options. That means changing it later might have no effect on these other classes (I didn't follow the code deep enough to be sure).

    Also it seems that the right thing to disable the cache is to use

    from suds.cache import NoCache
    # ...
    cli = suds.client.Client(url, cache=NoCache())
    

    because some parts of the code do not check for cache == None.

    However I can't tell for sure that my suggestion above will disable all caches as I've seen other posts on mailing lists which suggest that it might be hard to disable all caches unconditionally.