diff options
| author | Stephane Wirtel <stephane@tinyerp.com> | 2009-01-19 23:48:40 +0100 |
|---|---|---|
| committer | Stephane Wirtel <stephane@tinyerp.com> | 2009-01-19 23:48:40 +0100 |
| commit | a875a71408e1de8588f82ebd6d6b39bb92f040ed (patch) | |
| tree | c2015afe46ea0eed072f57a86dfc828f46e56d86 /bin/sql_db.py | |
| parent | d99f6b27d92975210972362a95b2e4ba3d783cd8 (diff) | |
[IMP] Improve the speed - Use the inspect module only if we specify the debug log level
bzr revid: stephane@tinyerp.com-20090119224840-j0yqyaw30tzfrc78
Diffstat (limited to 'bin/sql_db.py')
| -rw-r--r-- | bin/sql_db.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/bin/sql_db.py b/bin/sql_db.py index 3628213f307..118f8e900dc 100644 --- a/bin/sql_db.py +++ b/bin/sql_db.py @@ -82,21 +82,23 @@ class Cursor(object): self._obj = self._cnx.cursor(cursor_factory=psycopg1cursor) self.autocommit(False) self.dbname = pool.dbname - - from inspect import stack - self.__caller = tuple(stack()[2][1:3]) + + if tools.config['log_level'] in (netsvc.LOG_DEBUG, netsvc.LOG_DEBUG_RPC): + from inspect import stack + self.__caller = tuple(stack()[2][1:3]) def __del__(self): if hasattr(self, '_obj'): - # Oops. 'self' has not been closed explicitly. - # The cursor will be deleted by the garbage collector, - # but the database connection is not put back into the connection - # pool, preventing some operation on the database like dropping it. - # This can also lead to a server overload. - msg = "Cursor not closed explicitly\n" \ - "Cursor was created at %s:%s" % self.__caller - - log(msg, netsvc.LOG_WARNING) + if tools.config['log_level'] in (netsvc.LOG_DEBUG, netsvc.LOG_DEBUG_RPC): + # Oops. 'self' has not been closed explicitly. + # The cursor will be deleted by the garbage collector, + # but the database connection is not put back into the connection + # pool, preventing some operation on the database like dropping it. + # This can also lead to a server overload. + msg = "Cursor not closed explicitly\n" \ + "Cursor was created at %s:%s" % self.__caller + + log(msg, netsvc.LOG_WARNING) self.close() @check |
