[repo] fix multi-threads bug with get_option_value: pyro proxy can't be used from a thread to another without caution (closes #1535206) stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 09 Mar 2011 13:42:55 +0100
branchstable
changeset 7064 b8ce2266d026
parent 7063 b07ee816bffb
child 7065 6a6ea9966931
[repo] fix multi-threads bug with get_option_value: pyro proxy can't be used from a thread to another without caution (closes #1535206)
server/repository.py
--- a/server/repository.py	Wed Mar 09 12:24:50 2011 +0100
+++ b/server/repository.py	Wed Mar 09 13:42:55 2011 +0100
@@ -543,7 +543,13 @@
             return self.config[option]
         pool = self._get_pool()
         try:
-            return pool.connection(sourceuri).get_option_value(option, extid)
+            cnx = pool.connection(sourceuri)
+            # needed to check connection is valid and usable by the current
+            # thread
+            newcnx = self.sources_by_uri[sourceuri].check_connection(cnx)
+            if newcnx is not None:
+                cnx = newcnx
+            return cnx.get_option_value(option, extid)
         finally:
             self._free_pool(pool)