Skip to content
Snippets Groups Projects
Unverified Commit 10f5764b authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

changed how CallableGroup works - now every add adds a CancellableCallback

  and it's always true that CallableGroup has it's own cancellable callbacks.
parent 40c1564d
No related branches found
No related tags found
No related merge requests found
Pipeline #62130 failed with stages
in 1 minute and 16 seconds
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment