Skip to content

Commit

Permalink
fixup! client: Fix cache corruption on loadBefore and prefetch
Browse files Browse the repository at this point in the history
Correct Fut implemntation according to review feedback:

zopefoundation#169 (comment)
  • Loading branch information
navytux committed Apr 15, 2021
1 parent 3611bee commit fccd3b7
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/ZEO/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -894,24 +894,22 @@ class Fut(object):
"""Lightweight future that calls it's callbacks immediately rather than soon
"""

cbv = None
def __init__(self):
self.cbv = []

def add_done_callback(self, cb):
if self.cbv is None:
self.cbv = []
self.cbv.append(cb)

exc = None
def set_exception(self, exc):
self.exc = exc
if self.cbv:
for cb in self.cbv:
cb(self)
for cb in self.cbv:
cb(self)

def set_result(self, result):
self._result = result
if self.cbv:
for cb in self.cbv:
cb(self)
for cb in self.cbv:
cb(self)

def result(self):
if self.exc:
Expand Down

0 comments on commit fccd3b7

Please sign in to comment.