From 7938bf1f8c0461d92c12e39243dfacd2837dc408 Mon Sep 17 00:00:00 2001 From: qstokkink Date: Tue, 13 Nov 2018 11:06:57 +0100 Subject: [PATCH] Added support for delayed deferred with no value --- ipv8/attestation/trustchain/caches.py | 2 +- ipv8/taskmanager.py | 2 -- ipv8/test/test_taskmanager.py | 3 --- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/ipv8/attestation/trustchain/caches.py b/ipv8/attestation/trustchain/caches.py index e71271e8c..fe9bca5ec 100644 --- a/ipv8/attestation/trustchain/caches.py +++ b/ipv8/attestation/trustchain/caches.py @@ -107,7 +107,7 @@ def on_timeout(self): if self.timeouts < 360: self.community.send_block(self.half_block, address=self.socket_address) - def add_later(): + def add_later(_): self.community.request_cache.add(HalfBlockSignCache(self.community, self.half_block, self.sign_deferred, self.socket_address, self.timeouts + 1)) later = Deferred() diff --git a/ipv8/taskmanager.py b/ipv8/taskmanager.py index d813f08a8..d38961aea 100644 --- a/ipv8/taskmanager.py +++ b/ipv8/taskmanager.py @@ -54,8 +54,6 @@ def register_task(self, name, task, delay=None, value=None, interval=None): if delay is not None: if isinstance(task, Deferred): - if value is None: - raise ValueError("Expecting value to fire the Deferred with") dc = self._reactor.callLater(delay, task.callback, value) elif isinstance(task, LoopingCall): if interval is None: diff --git a/ipv8/test/test_taskmanager.py b/ipv8/test/test_taskmanager.py index e39feb018..e917c825d 100644 --- a/ipv8/test/test_taskmanager.py +++ b/ipv8/test/test_taskmanager.py @@ -56,9 +56,6 @@ def test_looping_call_and_cancel(self): def test_delayed_looping_call_requires_interval(self): self.assertRaises(ValueError, self.tm.register_task, "test", LoopingCall(lambda: None), delay=1) - def test_delayed_deferred_requires_value(self): - self.assertRaises(ValueError, self.tm.register_task, "test", deferLater(reactor, 0.0, lambda: None), delay=1) - def test_delayed_looping_call_requires_LoopingCall_or_Deferred(self): self.assertRaises(ValueError, self.tm.register_task, "test not Deferred nor LoopingCall", self.tm._reactor.callLater(0, lambda: None), delay=1)