diff options
| author | P. Christeas <p_christ@hol.gr> | 2010-11-23 15:57:42 +0200 |
|---|---|---|
| committer | P. Christeas <p_christ@hol.gr> | 2010-11-23 15:57:42 +0200 |
| commit | 6cd5fec0e295d7b25f6ee66ae4b7ab8bddf25306 (patch) | |
| tree | 00a1409ae8a18bac9e298fb4a872f9744ad2f385 /bin/sql_db.py | |
| parent | 962a4cce702bc69924cd09702690b8df6bfd6ef0 (diff) | |
sql_db: Avoid using inspect.stack(), use failsafe alternative.
Inspecting the full stack just to learn the file:line info for debugging
purposes is both expensive and error-prone. Write an alternative function
in tools/func.py that will just go N frames back and try to get the info.
bzr revid: p_christ@hol.gr-20101123135742-2jp75f3uxyg3a6b6
Diffstat (limited to 'bin/sql_db.py')
| -rw-r--r-- | bin/sql_db.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bin/sql_db.py b/bin/sql_db.py index 6c2c17beeb3..cdc3d0de4b3 100644 --- a/bin/sql_db.py +++ b/bin/sql_db.py @@ -51,11 +51,11 @@ psycopg2.extensions.register_type(psycopg2.extensions.new_type((700, 701, 1700,) import tools -from tools.func import wraps +from tools.func import wraps, frame_codeinfo from datetime import datetime as mdt from datetime import timedelta import threading -from inspect import stack +from inspect import currentframe import re re_from = re.compile('.* from "?([a-zA-Z_0-9]+)"? .*$'); @@ -93,7 +93,7 @@ class Cursor(object): self._obj = self._cnx.cursor(cursor_factory=psycopg1cursor) self.__closed = False # real initialisation value self.autocommit(False) - self.__caller = tuple(stack()[2][1:3]) + self.__caller = frame_codeinfo(currentframe(),2) def __del__(self): if not self.__closed: |
