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.
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):