diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-11-11 01:52:42 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-11-11 01:52:42 +0000 |
| commit | da0a8b913bc1336b85618edee0ef63ed96ea1ba0 (patch) | |
| tree | 6f127c40cccf698794389128ec1c83723fbda8c4 /lib | |
| parent | d403d8b865884b05169c7d56d0545e84088ba8a4 (diff) | |
| download | sqlalchemy-da0a8b913bc1336b85618edee0ef63ed96ea1ba0.tar.gz | |
- Adjustments to the enhanced garbage collection on
InstanceState to better guard against errors due
to lost state.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sqlalchemy/orm/attributes.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index e80392d0c..662ea05d3 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -799,7 +799,6 @@ class InstanceState(object): runid = None expired_attributes = EMPTY_SET insert_order = None - dict = None def __init__(self, obj, manager): self.class_ = obj.__class__ @@ -820,15 +819,23 @@ class InstanceState(object): def dispose(self): if self.session_id: del self.session_id - del self.dict del self.obj + del self.dict def _cleanup(self, ref): self.dispose() def obj(self): return None - + + @util.memoized_property + def dict(self): + # return a blank dict + # if none is available, so that asynchronous gc + # doesn't blow up expiration operations in progress + # (usually expire_attributes) + return {} + @property def sort_key(self): return self.key and self.key[1] or self.insert_order @@ -969,9 +976,6 @@ class InstanceState(object): if key not in self.committed_state and key not in self.dict) def expire_attributes(self, attribute_names): - if self.dict is None: - return - self.expired_attributes = set(self.expired_attributes) if attribute_names is None: |
