From fccd3b7fc6c5158219234fed213601746cbb5704 Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Thu, 15 Apr 2021 19:40:53 +0300 Subject: [PATCH] fixup! client: Fix cache corruption on loadBefore and prefetch Correct Fut implemntation according to review feedback: https://github.com/zopefoundation/ZEO/pull/169#discussion_r613622991 --- src/ZEO/asyncio/client.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/ZEO/asyncio/client.py b/src/ZEO/asyncio/client.py index 39598218..9e7ef6ab 100644 --- a/src/ZEO/asyncio/client.py +++ b/src/ZEO/asyncio/client.py @@ -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: