From 8878e2307954a98c894441613b6e836b3982556f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 19 Feb 2014 16:11:19 -0500 Subject: [PATCH] restore the check ahead of the lock to avoid using it after initialization is done --- lib/sqlalchemy/event/attr.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/sqlalchemy/event/attr.py b/lib/sqlalchemy/event/attr.py index ca94493f57..a3a0d48dcc 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.""" -- 2.47.3