diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-09-21 00:47:35 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2009-09-21 00:47:35 +0000 |
| commit | 7760e70d8d68355b5c0f13cce011f2c5da7b0823 (patch) | |
| tree | bb0036e2d4c662db5005728c5ec3a01bb247c327 /lib/sqlalchemy | |
| parent | 2acd40f0dc4e83d77d53097499b5d2090e000689 (diff) | |
| download | sqlalchemy-7760e70d8d68355b5c0f13cce011f2c5da7b0823.tar.gz | |
place the constructor level configuration within the COMPILE_MUTEX,
to prevent half-constructed mappers from getting sucked into the compile()
phase
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index 907fcd5c3..7c4ec23f6 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -192,16 +192,23 @@ class Mapper(object): self.exclude_properties = exclude_properties self.compiled = False - - self._configure_inheritance() - self._configure_extensions() - self._configure_class_instrumentation() - self._configure_properties() - self._configure_pks() - global _new_mappers - _new_mappers = True - self._log("constructed") - + + # prevent this mapper from being constructed + # while a compile() is occuring (and defer a compile() + # until construction succeeds) + _COMPILE_MUTEX.acquire() + try: + self._configure_inheritance() + self._configure_extensions() + self._configure_class_instrumentation() + self._configure_properties() + self._configure_pks() + global _new_mappers + _new_mappers = True + self._log("constructed") + finally: + _COMPILE_MUTEX.release() + # configurational / mutating methods. not threadsafe # except for compile(). |
