From: Jason Kirtland Date: Tue, 15 Jul 2008 19:56:30 +0000 (+0000) Subject: - Always use native threading.local (or the native dummy version) X-Git-Tag: rel_0_5beta3~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acbfb9ea2b78b97800356e8dec2c977e54447182;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - Always use native threading.local (or the native dummy version) --- diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index a389ccca4f..6885855902 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):