diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-07-11 15:15:09 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-07-11 15:15:09 -0400 |
commit | fd55be01ddc0ab41dd9469c6c7736d12d5a2f1ea (patch) | |
tree | 460612226d5710aaf151f7552fcba6c1f7cbcd42 /lib/sqlalchemy/util/langhelpers.py | |
parent | cd8a40284d0fb053f652f4a3d2745c22674603f8 (diff) | |
download | sqlalchemy-fd55be01ddc0ab41dd9469c6c7736d12d5a2f1ea.tar.gz |
Dialect.initialize() is not called a second time if an :class:`.Engine`
is recreated, due to a disconnect error. This fixes a particular
issue in the Oracle 8 dialect, but in general the dialect.initialize()
phase should only be once per dialect. Also in 0.8.3. [ticket:2776]
Diffstat (limited to 'lib/sqlalchemy/util/langhelpers.py')
-rw-r--r-- | lib/sqlalchemy/util/langhelpers.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index c91178a75..d63cc8e2a 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -1047,6 +1047,20 @@ _SQLA_RE = re.compile(r'sqlalchemy/([a-z_]+/){0,2}[a-z_]+\.py') _UNITTEST_RE = re.compile(r'unit(?:2|test2?/)') +def only_once(fn): + """Decorate the given function to be a no-op after it is called exactly + once.""" + + once = [fn] + def go(*arg, **kw): + if once: + once_fn = once.pop() + return once_fn(*arg, **kw) + + return update_wrapper(go, fn) + + + def chop_traceback(tb, exclude_prefix=_UNITTEST_RE, exclude_suffix=_SQLA_RE): """Chop extraneous lines off beginning and end of a traceback. |