Trouble storing Suds SOAP client in Configurator registry

32 views
Skip to first unread message

ian marcinkowski

unread,
May 23, 2013, 3:19:32 PM5/23/13
to Pyramid Mailinglist
Are objects modified when they are saved in the Configurator registry.settings dictionary?

I am trying to store a Suds SOAP Client in the registry which can be cloned in my view-callables so I can avoid re-parsing that WSDL document.  When I am trying to clone the Suds Client that has been stored in the registry, my app is crashing horribly due to a maximum recursion limit reached exception.

Some code:

In my app __init__.py:
def main(global_config, **app_settings):
  settings = {}
  ...
  settings['soap_client'] = suds.client.Client('file:///service.wsdl', username='foo', password='bar')

  config = Configurator(settings=settings,  ...)
  return config.make_wsgi_app()

view-callable.py
def view(request):
  cloned_soap_client = request.registry.settings['soap_client'].clone() <-- Induces Max. Recursion exception
  return cloned_soap_client.service.SomeMethod()

If I drop in to a PDB terminal inside of my application's main() function and try cloneing settings['soap_client'] I do not encounter this recursion limit.

Sure, this is probably an bug with the Suds client, but I'm not sure how toreproduce it outside of my application.

Thoughts?

--
Ian Marcinkowski
ianmarc...@gmail.com

Michael Merickel

unread,
May 23, 2013, 3:35:40 PM5/23/13
to Pylons
The settings dictionary is copied once when you pass it into the configurator, and it is supposed to be a shallow copy.

new_settings = {}
new_settings.update(settings)

That doesn't explain your issue though.

A likely fix is just to follow the pattern I use, which is to leave the settings dictionary for primitive types. Services and utilities are things I attach to the registry itself (it's a dict too).





--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

ian marcinkowski

unread,
May 27, 2013, 9:47:31 AM5/27/13
to Pyramid Mailinglist
Attaching my Suds Client to the registry did not help, but I will keep that pattern in mind.

Thanks!

--
Ian Marcinkowski
ianmarc...@gmail.com

Michael Merickel

unread,
May 27, 2013, 12:37:10 PM5/27/13
to Pylons
It's *really* difficult for the internet to help debug your problems without a full traceback. You're basically asking if anyone has seen this exact problem before because they have no other context to help them out.

Anyway, Pyramid does not copy anything that is in the settings or the registry. Are you sure your client is threadsafe? If you're touching a non-threadsafe object from multiple request threads then anything could happen.

ian marcinkowski

unread,
May 28, 2013, 3:47:30 PM5/28/13
to Pyramid Mailinglist
I know how difficult things are without the traceback; I was mostly
looking for a suggestion exactly like yours in the hopes that it would
push me in the right direction. I actually didn't even get a
traceback, as my application crashed hard enough that it did not
output an error.

According to a few locations online, the Suds Client object is not
threadsafe, so that could have something to do with it. I am
reimplementing this with a threadsafe connection pool instead.

Michael Merickel

unread,
May 28, 2013, 4:50:18 PM5/28/13
to Pylons
FWIW, if you need a threadsafe connection pool and are already using SQLAlchemy for something else, the QueuePool is not db-api specific at all and can be reused for arbitrary connection pooling.

ian marcinkowski

unread,
May 29, 2013, 8:51:54 AM5/29/13
to Pyramid Mailinglist
Thanks!

I will take a look at that.
Reply all
Reply to author
Forward
0 new messages