From: Mike Bayer Date: Wed, 5 Nov 2008 19:08:02 +0000 (+0000) Subject: - Fixed RLock-related bug in mapper which could deadlock upon X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=068836ab42f77ac237699d89bc6d3d545a29860a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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. --- diff --git a/CHANGES b/CHANGES index 0c46077342..6081f9171e 100644 --- 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 ===== diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index b86fdc07b1..c35dbd5a35 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -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):