On 10/23/2012 04:52 PM, Rob Crittenden wrote:
> Close connection after each request, avoid NSS shutdown problem.
> 
> The unit tests were failing when executed against an Apache server
> in F-18 due to dangling references causing NSS shutdown to fail, and
> potentially other places like adding host keys during client enrollment.
> 
> rob
> 

This works very well in Fedora 18 (Python 2.7.3), but cause crashes with Python
2.6.x:

# ./make-testcert
ipa: ERROR: non-public: AttributeError: KerbTransport instance has no attribute
'_connection'
Traceback (most recent call last):
  File "/root/freeipa-master/ipalib/backend.py", line 129, in execute
    result = self.Command[_name](*args, **options)
  File "/root/freeipa-master/ipalib/frontend.py", line 435, in __call__
    ret = self.run(*args, **options)
  File "/root/freeipa-master/ipalib/frontend.py", line 748, in run
    return self.forward(*args, **options)
  File "/root/freeipa-master/ipalib/frontend.py", line 769, in forward
    return self.Backend.xmlclient.forward(self.name, *args, **kw)
  File "/root/freeipa-master/ipalib/rpc.py", line 538, in forward
    response = command(*xml_wrap(params))
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1199, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in __request
    verbose=self.__verbose
  File "/usr/lib64/python2.6/xmlrpclib.py", line 1228, in request
    h = self.make_connection(host)
  File "/root/freeipa-master/ipalib/rpc.py", line 261, in make_connection
    if self._connection and host == self._connection[0]:
AttributeError: KerbTransport instance has no attribute '_connection'
Traceback (most recent call last):
  File "./make-testcert", line 134, in <module>
    sys.exit(makecert(reqdir))
  File "./make-testcert", line 101, in makecert
    res = api.Backend.client.run('config_show')
  File "./make-testcert", line 68, in run
    result = self.execute(method, *args, **options)
  File "/root/freeipa-master/ipalib/backend.py", line 142, in execute
    destroy_context()
  File "/root/freeipa-master/ipalib/request.py", line 56, in destroy_context
    value.disconnect()
  File "/root/freeipa-master/ipalib/backend.py", line 78, in disconnect
    self.destroy_connection()
  File "/root/freeipa-master/ipalib/rpc.py", line 516, in destroy_connection
    conn.close()
AttributeError: KerbTransport instance has no attribute 'close'


Attaching a diff that made it working for me on Python 2.6.x.

Martin
diff -u b/ipalib/rpc.py b/ipalib/rpc.py
--- b/ipalib/rpc.py
+++ b/ipalib/rpc.py
@@ -257,7 +257,7 @@
         # If we an existing connection exists using the same NSS database
         # there is no need to re-initialize. Pass thsi into the NSS
         # connection creator.
-        if sys.version_info > (2, 6):
+        if sys.version_info >= (2, 7):
             if self._connection and host == self._connection[0]:
                 return self._connection[1]
 
@@ -509,7 +509,7 @@
         return serverproxy
 
     def destroy_connection(self):
-        if sys.version_info > (2, 6):
+        if sys.version_info >= (2, 7):
             conn = getattr(context, self.id, None)
             if conn is not None:
                 conn = conn.conn._ServerProxy__transport
_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to