-- cgit v1.2.1 From 46385c80c73671751c72c6c5fb68e34f0d7bdfaf Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 11 Oct 2014 15:18:45 -0700 Subject: Fix simulatenous 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. --- six.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/six.py b/six.py index 4252fdf..0df4538 100644 --- a/six.py +++ b/six.py @@ -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 -- cgit v1.2.1