]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
restore check ahead of the lock to avoid locking when not needed
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 19 Feb 2014 21:12:36 +0000 (16:12 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 19 Feb 2014 21:12:36 +0000 (16:12 -0500)
lib/sqlalchemy/event.py

index ec8481caf37faed88a106cc86066c32156e60ff8..ab25c660f3ce5e31c57cccd2ab9c411bfe384dc0 100644 (file)
@@ -394,12 +394,13 @@ class _CompoundListener(object):
         """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
 
 
     # I'm not entirely thrilled about the overhead here,