]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
restore the check ahead of the lock to avoid using it after initialization
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 19 Feb 2014 21:11:19 +0000 (16:11 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 19 Feb 2014 21:11:19 +0000 (16:11 -0500)
is done

lib/sqlalchemy/event/attr.py

index ca94493f578b4001d62616142bb231f81d7ed6fa..a3a0d48dccfeecb31bd5b6585635ce377cad1fbf 100644 (file)
@@ -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."""