summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2013-01-10 06:41:15 -0800
committerZac Medico <zmedico@gentoo.org>2013-01-10 06:41:15 -0800
commit8451f343034831bfc8dd06dd55fbce40b320882c (patch)
treedc5f4b924af92556c10682cf3ef4741052e3b6fc
parentc811cbf837e9a81f656d7883a231e23c209c73de (diff)
downloadportage-8451f343034831bfc8dd06dd55fbce40b320882c.tar.gz
portage-8451f343034831bfc8dd06dd55fbce40b320882c.tar.bz2
portage-8451f343034831bfc8dd06dd55fbce40b320882c.zip
Revert "_ctypes: don't cache library, bug #448858"v2.2.0_alpha150
This reverts commit 9e37cca4f54260bd8c45a3041fcee00938c71649. As noted in bug #448858, comment #14, dlclose is not called automatically, so we may as well cache our library handles. In order to protect ourselves, we use a fork since commit 7ebb2f54877edb28621c33e380f8777b1b1dc201.
-rw-r--r--pym/portage/util/_ctypes.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/pym/portage/util/_ctypes.py b/pym/portage/util/_ctypes.py
index f419b1926..4e5aa2a6b 100644
--- a/pym/portage/util/_ctypes.py
+++ b/pym/portage/util/_ctypes.py
@@ -31,15 +31,17 @@ def find_library(name):
return None
return filename
+_library_handles = {}
+
def LoadLibrary(name):
"""
Calls ctypes.cdll.LoadLibrary(name) if the ctypes module is available,
- and otherwise returns None. Results are not cached, since that can
- cause problems when libraries are updated (see bug #448858).
+ and otherwise returns None. Results are cached for future invocations.
"""
- handle = None
+ handle = _library_handles.get(name)
- if ctypes is not None:
+ if handle is None and ctypes is not None:
handle = ctypes.cdll.LoadLibrary(name)
+ _library_handles[name] = handle
return handle