[FIX] Use the currentThread function instead of current_thread
bzr revid: stephane@openerp.com-20100906140645-zxt6los8sl54qzj0
This commit is contained in:
parent
56d507a7e1
commit
6b2e5f9896
|
@ -167,7 +167,7 @@ LEVEL_COLOR_MAPPING = {
|
|||
|
||||
class DBFormatter(logging.Formatter):
|
||||
def format(self, record):
|
||||
record.dbname = getattr(threading.current_thread(), 'dbname', '?')
|
||||
record.dbname = getattr(threading.currentThread(), 'dbname', '?')
|
||||
return logging.Formatter.format(self, record)
|
||||
|
||||
class ColoredFormatter(DBFormatter):
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
__all__ = ['db_connect', 'close_db']
|
||||
|
||||
from threading import current_thread
|
||||
from threading import currentThread
|
||||
import logging
|
||||
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT, ISOLATION_LEVEL_READ_COMMITTED, ISOLATION_LEVEL_SERIALIZABLE
|
||||
from psycopg2.psycopg1 import cursor as psycopg1cursor
|
||||
|
@ -365,13 +365,13 @@ def dsn_are_equals(first, second):
|
|||
_Pool = ConnectionPool(int(tools.config['db_maxconn']))
|
||||
|
||||
def db_connect(db_name):
|
||||
current_thread().dbname = db_name
|
||||
currentThread().dbname = db_name
|
||||
return Connection(_Pool, db_name)
|
||||
|
||||
def close_db(db_name):
|
||||
_Pool.close_all(dsn(db_name))
|
||||
tools.cache.clean_caches_for_db(db_name)
|
||||
ct = current_thread()
|
||||
ct = currentThread()
|
||||
if hasattr(ct, 'dbname'):
|
||||
delattr(ct, 'dbname')
|
||||
|
||||
|
|
Loading…
Reference in New Issue