Commits

Mike Bayer committed 68710ba

- 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.

Comments (0)

Files changed (2)

     - 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
 =====

lib/sqlalchemy/orm/mapper.py

             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:
+                # 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()
+
+                _new_mappers = False
                 return self
-
-            # initialize properties on all mappers
-            for mapper in list(_mapper_registry):
-                if not mapper.__props_init:
-                    mapper.__initialize_properties()
-
-            _new_mappers = False
-            return self
+            finally:
+                _already_compiling = False
         finally:
-            _already_compiling = False
             _COMPILE_MUTEX.release()
 
     def __initialize_properties(self):