From: Mike Bayer Date: Sat, 30 May 2009 01:09:16 +0000 (+0000) Subject: removed needless "thread" imports from util X-Git-Tag: rel_0_5_5~25 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=13d4004774b8ea14e8ef1614bea7105122878748;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git removed needless "thread" imports from util --- diff --git a/lib/sqlalchemy/engine/threadlocal.py b/lib/sqlalchemy/engine/threadlocal.py index 23c9cd0c1e..8ad14ad35f 100644 --- a/lib/sqlalchemy/engine/threadlocal.py +++ b/lib/sqlalchemy/engine/threadlocal.py @@ -172,7 +172,7 @@ class TLEngine(base.Engine): """Construct a new TLEngine.""" super(TLEngine, self).__init__(*args, **kwargs) - self.context = util.ThreadLocal() + self.context = util.threading.local() proxy = kwargs.get('proxy') if proxy: diff --git a/lib/sqlalchemy/pool.py b/lib/sqlalchemy/pool.py index dabc2929ee..2eabd85727 100644 --- a/lib/sqlalchemy/pool.py +++ b/lib/sqlalchemy/pool.py @@ -20,7 +20,7 @@ import weakref, time, threading from sqlalchemy import exc, log from sqlalchemy import queue as Queue -from sqlalchemy.util import thread, threading, pickle, as_interface +from sqlalchemy.util import threading, pickle, as_interface proxies = {} diff --git a/lib/sqlalchemy/queue.py b/lib/sqlalchemy/queue.py index 37e772547d..c9ab82acf8 100644 --- a/lib/sqlalchemy/queue.py +++ b/lib/sqlalchemy/queue.py @@ -1,7 +1,7 @@ """An adaptation of Py2.3/2.4's Queue module which supports reentrant behavior, using RLock instead of Lock for its mutex object. -This is to support the connection pool's usage of ``__del__`` to return +This is to support the connection pool's usage of weakref callbacks to return connections to the underlying Queue, which can apparently in extremely rare cases be invoked within the ``get()`` method of the Queue itself, producing a ``put()`` inside the ``get()`` and therefore a reentrant @@ -9,7 +9,7 @@ condition.""" from collections import deque from time import time as _time - +from sqlalchemy.util import threading __all__ = ['Empty', 'Full', 'Queue'] @@ -30,10 +30,6 @@ class Queue: If `maxsize` is <= 0, the queue size is infinite. """ - try: - import threading - except ImportError: - import dummy_threading as threading self._init(maxsize) # mutex must be held whenever the queue is mutating. All methods # that acquire mutex must release it before returning. mutex diff --git a/lib/sqlalchemy/schema.py b/lib/sqlalchemy/schema.py index 47c01024c7..2ec359f381 100644 --- a/lib/sqlalchemy/schema.py +++ b/lib/sqlalchemy/schema.py @@ -1833,7 +1833,7 @@ class ThreadLocalMetaData(MetaData): def __init__(self): """Construct a ThreadLocalMetaData.""" - self.context = util.ThreadLocal() + self.context = util.threading.local() self.__engines = {} super(ThreadLocalMetaData, self).__init__() diff --git a/lib/sqlalchemy/util.py b/lib/sqlalchemy/util.py index dbc7d3ea48..8eeeda4555 100644 --- a/lib/sqlalchemy/util.py +++ b/lib/sqlalchemy/util.py @@ -11,12 +11,9 @@ types = __import__('types') from sqlalchemy import exc try: - import thread, threading - from threading import local as ThreadLocal + import threading except ImportError: - import dummy_thread as thread import dummy_threading as threading - from dummy_threading import local as ThreadLocal py3k = getattr(sys, 'py3kwarning', False) or sys.version_info >= (3, 0)