-
-
Notifications
You must be signed in to change notification settings - Fork 718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEADLOCK: fetch->forgotten->fetch #6480
Comments
I wouldn't want to rely too much on weakref logic since we currently do not guarantee TaskState references to be actually properly released, see #6250 can you outline how this would look like? Another solution would be to track even more state using some unique identifier (e.g. class UniqueTaskHeap(Collection[TaskState]):
__slots__ = ("_known", "_heap")
_known: dict[int, str]
_heap: list[tuple[tuple[int, ...], int, str, TaskState]]
def discard(self, ts):
self._known.pop(id(ts))
def pop(self) -> TaskState:
while True:
_, _id, key, ts = heapq.heappop(self._heap)
try:
self._known.pop(_id)
except KeyError:
continue
return ts |
No worries, the weakref is just for memory efficiency. See linked PR |
Thanks for reporting and working on a fix @crusaderky. Do you know when this was introduced? I'd like to know if it's been around for a bit, or is a regression in the latest release |
It was introduced together with |
Log
Reproducer
The test deadlock on the last line.
freeze_data_fetching
is from #6342.Proposed design
UniqueTaskHeap
with a genericHeapSet
, which is a MutableSet wherepop()
returns the first element according to an arbitrary key function. You can discard keys from the middle of the heap, like in any other set. Internally it's implemented using weakrefs.The text was updated successfully, but these errors were encountered: