summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/util.py
diff options
context:
space:
mode:
authorJason Kirtland <jek@discorporate.us>2008-07-15 19:56:30 +0000
committerJason Kirtland <jek@discorporate.us>2008-07-15 19:56:30 +0000
commitacbfb9ea2b78b97800356e8dec2c977e54447182 (patch)
treedcd90214699467e162654fa8a6456856f158e040 /lib/sqlalchemy/util.py
parent4f56fd23bcd6c0adc11138fa50249095c7d4dd73 (diff)
downloadsqlalchemy-acbfb9ea2b78b97800356e8dec2c977e54447182.tar.gz
- Always use native threading.local (or the native dummy version)
Diffstat (limited to 'lib/sqlalchemy/util.py')
-rw-r--r--lib/sqlalchemy/util.py28
1 files changed, 2 insertions, 26 deletions
diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py
index a389ccca4..688585590 100644
--- a/lib/sqlalchemy/util.py
+++ b/lib/sqlalchemy/util.py
@@ -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):