diff options
author | Joshua Harlow <harlowja@gmail.com> | 2014-10-11 15:18:45 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2014-10-11 15:18:45 -0700 |
commit | 46385c80c73671751c72c6c5fb68e34f0d7bdfaf (patch) | |
tree | 9cb671db1a7882546ed16ddecf0a200083fc9a1f | |
parent | 908aadf4c03110f0be630c601717eca9e3872e59 (diff) | |
download | six-46385c80c73671751c72c6c5fb68e34f0d7bdfaf.tar.gz |
Fix simulatenous delattrfix-delattr
When two or more threads enter the descriptor one of them
will delete the attribute and the others will not be able
to, we should handle that case more gracefully.
-rw-r--r-- | six.py | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -88,8 +88,12 @@ class _LazyDescr(object): def __get__(self, obj, tp): result = self._resolve() setattr(obj, self.name, result) # Invokes __set__. - # This is a bit ugly, but it avoids running this again. - delattr(obj.__class__, self.name) + try: + # This is a bit ugly, but it avoids running this again by + # removing this descriptor. + delattr(obj.__class__, self.name) + except AttributeError: + pass return result |