From: Mike Bayer Date: Wed, 19 Feb 2014 21:11:19 +0000 (-0500) Subject: restore the check ahead of the lock to avoid using it after initialization X-Git-Tag: rel_0_9_3~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8878e2307954a98c894441613b6e836b3982556f;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git restore the check ahead of the lock to avoid using it after initialization is done --- 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."""