self._list.remove(item[0])
return item
-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["%d_%s" % (thread.get_ident(), key)]
- except KeyError:
- raise AttributeError(key)
-
- def __getattr__(self, key):
- try:
- return self._tdict["%d_%s" % (thread.get_ident(), key)]
- except KeyError:
- raise AttributeError(key)
-
- def __setattr__(self, key, value):
- self._tdict["%d_%s" % (thread.get_ident(), key)] = value
+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 DictDecorator(dict):
"""A Dictionary that delegates items not found to a second wrapped dictionary."""
help="Use mock pool (asserts only one connection used)")
opt("--enginestrategy", action="callback", type="string",
callback=_engine_strategy,
- help="Engine strategy (plain or threadlocal, defaults toplain)")
+ help="Engine strategy (plain or threadlocal, defaults to plain)")
opt("--reversetop", action="store_true", dest="reversetop", default=False,
help="Reverse the collection ordering for topological sorts (helps "
"reveal dependency issues)")