]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- Fixed RLock-related bug in mapper which could deadlock upon
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 5 Nov 2008 19:08:02 +0000 (19:08 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 5 Nov 2008 19:08:02 +0000 (19:08 +0000)
reentrant mapper compile() calls, something that occurs when
using declarative constructs inside of ForeignKey objects.
Ported from 0.5.

CHANGES
lib/sqlalchemy/orm/mapper.py

diff --git a/CHANGES b/CHANGES
index 0c460773428a1f189e799d706a9b3c0037257467..6081f9171e7e6e7b9b73a9e569e1f2410a4005b5 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -10,6 +10,11 @@ CHANGES
     - Fixed 0.4-only bug preventing composite columns
       from working properly with inheriting mappers
       [ticket:1199]
+
+    - Fixed RLock-related bug in mapper which could deadlock upon
+      reentrant mapper compile() calls, something that occurs when
+      using declarative constructs inside of ForeignKey objects.
+      Ported from 0.5.
       
 0.4.8
 =====
index b86fdc07b18c575f60073f11a3a6c540c56c5744..c35dbd5a357c3d340c3bdafac9cd87d7b1f20f63 100644 (file)
@@ -333,26 +333,28 @@ class Mapper(object):
             return self
             
         _COMPILE_MUTEX.acquire()
-        global _already_compiling
-        if _already_compiling:
-            self.__initialize_properties()
-            return
-        _already_compiling = True
         try:
+            global _already_compiling
+            if _already_compiling:
+                self.__initialize_properties()
+                return
+            _already_compiling = True
+            try:
 
-            # double-check inside mutex
-            if self.__props_init and not _new_mappers:
-                return self
+                # double-check inside mutex
+                if self.__props_init and not _new_mappers:
+                    return self
 
-            # initialize properties on all mappers
-            for mapper in list(_mapper_registry):
-                if not mapper.__props_init:
-                    mapper.__initialize_properties()
+                # initialize properties on all mappers
+                for mapper in list(_mapper_registry):
+                    if not mapper.__props_init:
+                        mapper.__initialize_properties()
 
-            _new_mappers = False
-            return self
+                _new_mappers = False
+                return self
+            finally:
+                _already_compiling = False
         finally:
-            _already_compiling = False
             _COMPILE_MUTEX.release()
 
     def __initialize_properties(self):