Hello,
I would like to use suds to talk to several SOAP services, each using the same WSDL. The wsdl file is rather large (about 500K) and translates to about 50M of memory once parsed.
If I do this: c1 = Client('file:myservice.wsdl) c1.set_options(location="https://addr1/soap") c2 = Client('file:myservice.wsdl) c2.set_options(location="https://addr2/soap") (etc)
Then each Client instance adds about 50M to my program's memory footprint. Is there any way to parse the WSDL once and create several client objects based on the already-parsed file?
A cursory inspection of the Client code suggests I might be able to create the first Client() and then make new instances of client that reference the wsdl, factory and sd members of the original, but contains different Options and possibly it's own ServiceSelector.
Suggestions or comments? --Chris
On 09/10/2009 11:00 AM, Chris Frantz wrote:
Hello,
I would like to use suds to talk to several SOAP services, each using the same WSDL. The wsdl file is rather large (about 500K) and translates to about 50M of memory once parsed.
If I do this: c1 = Client('file:myservice.wsdl) c1.set_options(location="https://addr1/soap") c2 = Client('file:myservice.wsdl) c2.set_options(location="https://addr2/soap") (etc)
Then each Client instance adds about 50M to my program's memory footprint. Is there any way to parse the WSDL once and create several client objects based on the already-parsed file?
Not really.
A cursory inspection of the Client code suggests I might be able to create the first Client() and then make new instances of client that reference the wsdl, factory and sd members of the original, but contains different Options and possibly it's own ServiceSelector.
This approach is your best bet. Let me tweak a few things to facilitate this.
Suggestions or comments? --Chris
fedora-suds-list mailing list fedora-suds-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-suds-list
Jeff,
Here is a patch that allows new Client instances to be based off an existing Client. This appears to work fine, but it hasn't been extensively tested.
Best Regards, --Chris
--- client.py 2009-09-14 10:35:35.000000000 -0500 +++ ../../python-suds-0.3.7/suds/client.py 2009-09-10 11:47:22.000000000 -0500 @@ -98,18 +98,27 @@ @param kwargs: keyword arguments. @see: L{Options} """ + base = None + if 'base' in kwargs: + base = kwargs['base'] + del kwargs['base'] options = Options() options.cache = FileCache(days=1) options.transport = HttpAuthenticated() options.set(**kwargs) self.options = options - self.wsdl = Definitions(url, options) - self.factory = Factory(self.wsdl) + if base: + self.wsdl = base.wsdl + self.factory = base.factory + self.sd = base.sd + else: + self.wsdl = Definitions(url, options) + self.factory = Factory(self.wsdl) + self.sd = [] + for s in self.wsdl.services: + sd = ServiceDefinition(self.wsdl, s) + self.sd.append(sd) self.service = ServiceSelector(self, self.wsdl.services) - self.sd = [] - for s in self.wsdl.services: - sd = ServiceDefinition(self.wsdl, s) - self.sd.append(sd) self.messages = dict(tx=None, rx=None)
def set_options(self, **kwargs):
On 09/10/2009 03:37 PM, Jeff Ortel wrote:
On 09/10/2009 11:00 AM, Chris Frantz wrote:
Hello,
I would like to use suds to talk to several SOAP services, each using the same WSDL. The wsdl file is rather large (about 500K) and translates to about 50M of memory once parsed.
If I do this: c1 = Client('file:myservice.wsdl) c1.set_options(location="https://addr1/soap") c2 = Client('file:myservice.wsdl) c2.set_options(location="https://addr2/soap") (etc)
Then each Client instance adds about 50M to my program's memory footprint. Is there any way to parse the WSDL once and create several client objects based on the already-parsed file?
Not really.
A cursory inspection of the Client code suggests I might be able to create the first Client() and then make new instances of client that reference the wsdl, factory and sd members of the original, but contains different Options and possibly it's own ServiceSelector.
This approach is your best bet. Let me tweak a few things to facilitate this.
I added a Client.clone() method to help provide for cases like yours where users want to read the wsdl once and then create many (thin) clones to support usage in multiple threads with a minimal memory footprint. I added clone() in a previous revision but it needed some Options refactoring and __deepcopy__() tweaking in the HttpTransport hierarchy to really behave correctly. The clone() provides for sharing the wsdl but allowing for independent Options and Transports.
Anyway, I know you cooked up a solution which is great. But, I don't really have a good test environment for this and I'd appreciate your giving it a try.
Thanks
-jeff
Suggestions or comments? --Chris
fedora-suds-list mailing list fedora-suds-list@redhat.com https://www.redhat.com/mailman/listinfo/fedora-suds-list