]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Always use native threading.local (or the native dummy version)
authorJason Kirtland <jek@discorporate.us>
Tue, 15 Jul 2008 19:56:30 +0000 (19:56 +0000)
committerJason Kirtland <jek@discorporate.us>
Tue, 15 Jul 2008 19:56:30 +0000 (19:56 +0000)
lib/sqlalchemy/util.py

index a389ccca4fc74980ebb0e282e956e265515c4528..68858559026408c2ea02bf117b91dbfe82ed78f6 100644 (file)
@@ -12,9 +12,11 @@ from sqlalchemy import exc
 
 try:
     import thread, threading
+    from threading import local as ThreadLocal
 except ImportError:
     import dummy_thread as thread
     import dummy_threading as threading
+    from dummy_threading import local as ThreadLocal
 
 # TODO: 2.6 will whine about importing `sets`, but I think we still need it to
 # around to support older DB-API modules that return the 2.3 style set.
@@ -668,32 +670,6 @@ class OrderedDict(dict):
         self._list.remove(item[0])
         return item
 
-try:
-    from threading import local as ThreadLocal
-except ImportError:
-    try:
-        from dummy_threading import local as ThreadLocal
-    except ImportError:
-        class ThreadLocal(object):
-            """An object in which attribute access occurs only within the context of the current thread."""
-
-            def __init__(self):
-                self.__dict__['_tdict'] = {}
-
-            def __delattr__(self, key):
-                try:
-                    del self._tdict[(thread.get_ident(), key)]
-                except KeyError:
-                    raise AttributeError(key)
-
-            def __getattr__(self, key):
-                try:
-                    return self._tdict[(thread.get_ident(), key)]
-                except KeyError:
-                    raise AttributeError(key)
-
-            def __setattr__(self, key, value):
-                self._tdict[(thread.get_ident(), key)] = value
 
 class OrderedSet(set):
     def __init__(self, d=None):