[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-09-07 Thread Antoine Pitrou
Antoine Pitrou added the comment: In addition to _NOT_FOUND and _EXCEPTION_RAISED, you could have an additional sentinel value _CONCURRENTLY_COMPUTING. Then you don't need to maintain a separate self.updater mapping. -- nosy: +pitrou ___ Python

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-08-26 Thread Alessio Bogon
Change by Alessio Bogon : -- nosy: +youtux ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-08-04 Thread Raymond Hettinger
Change by Raymond Hettinger : -- keywords: +patch pull_requests: +26104 stage: -> patch review pull_request: https://github.com/python/cpython/pull/27609 ___ Python tracker

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-08-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: Here's the latest effort: --- def __get__(self, instance, owner=None): if instance is None: return self if self.attrname is None: raise TypeError(

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-08-03 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > It should use "(id(instance), instance)" rather than just "instance" as the > key. It should use a dict with id(instance) as a key and instance as value. An instance can be non-hashable. -- ___ Python

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-08-01 Thread Joshua Bronson
Change by Joshua Bronson : -- nosy: +jab ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-08-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: > It is hard to get rid of the execution lock once > it was introduced, but I think we should do it. It's likely some apps are relying on the locking feature. So if we can fix it, we should do prefer that over more disruptive changes. Addenda to my code

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-08-01 Thread Raymond Hettinger
Change by Raymond Hettinger : -- nosy: +carljm, ncoghlan, pydanny ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-08-01 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think it was a mistake to use lock in cached_property at first place. In most cases there is nothing wrong in evaluating the cached value more than once. lru_cache() does not use a lock for calling the wrapped function, and it works well. The only lock

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-07-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: Antti Haapala, I agree that this situation is catastrophic and that we need some way to avoid blocking parallel calculations of cached values for distinct instances of the same class. Here's an idea that might possibly work. Perhaps, hold one lock only

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-07-27 Thread Thomas Grainger
Thomas Grainger added the comment: > using a per-descriptor `WeakKeyDictionary` to map the instance to locks > (which would of course not work - is there any way to map unhashable > instances weakly?) there's an issue for that too: https://bugs.python.org/issue44140 --

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-07-27 Thread Thomas Grainger
Thomas Grainger added the comment: how about deprecating the functools.cached_property? -- nosy: +graingert ___ Python tracker ___

[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-03-17 Thread Antti Haapala
Change by Antti Haapala : -- title: functools.cached_property locking is plain wrong. -> functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking ___ Python tracker