From 10f5764b83998b73a8abb15159ff6593b88bbfa7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@ericsson.com> Date: Mon, 2 Sep 2024 11:09:46 +0200 Subject: [PATCH] changed how CallableGroup works - now every add adds a CancellableCallback and it's always true that CallableGroup has it's own cancellable callbacks. --- satella/coding/concurrent/callablegroup.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/satella/coding/concurrent/callablegroup.py b/satella/coding/concurrent/callablegroup.py index 87053433..ecf3fd6e 100644 --- a/satella/coding/concurrent/callablegroup.py +++ b/satella/coding/concurrent/callablegroup.py @@ -4,11 +4,10 @@ import time import typing as tp from satella.coding.deleters import DictDeleter -from satella.coding.structures.mixins import HashableMixin from satella.coding.typing import T, NoArgCallable -class CancellableCallback(HashableMixin): +class CancellableCallback: """ A callback that you can cancel. @@ -36,6 +35,12 @@ class CancellableCallback(HashableMixin): self.callback_fun = callback_fun self.cancelled = False + def __hash__(self): + return hash(self.id) + + def __eq__(self, other) -> bool: + return hash(self) == hash(other) + def __call__(self, *args, **kwargs): if not self.cancelled: return self.callback_fun(*args, **kwargs) -- GitLab