summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2014-02-19 16:11:19 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2014-02-19 16:11:19 -0500
commit8878e2307954a98c894441613b6e836b3982556f (patch)
tree168122de1606f9b3100643efc04563c91ce0fd91
parent033463cd4bd93739e0642ed9ef440a0c9d3374fe (diff)
downloadsqlalchemy-8878e2307954a98c894441613b6e836b3982556f.tar.gz
restore the check ahead of the lock to avoid using it after initialization
is done
-rw-r--r--lib/sqlalchemy/event/attr.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/sqlalchemy/event/attr.py b/lib/sqlalchemy/event/attr.py
index ca94493f5..a3a0d48dc 100644
--- a/lib/sqlalchemy/event/attr.py
+++ b/lib/sqlalchemy/event/attr.py
@@ -240,12 +240,13 @@ class _CompoundListener(_HasParentDispatchDescriptor):
"""Execute this event, but only if it has not been
executed already for this collection."""
- with self._exec_once_mutex:
- if not self._exec_once:
- try:
- self(*args, **kw)
- finally:
- self._exec_once = True
+ if not self._exec_once:
+ with self._exec_once_mutex:
+ if not self._exec_once:
+ try:
+ self(*args, **kw)
+ finally:
+ self._exec_once = True
def __call__(self, *args, **kw):
"""Execute this event."""