Skip to content

Commit

Permalink
Added support for delayed deferred with no value
Browse files Browse the repository at this point in the history
  • Loading branch information
qstokkink committed Nov 13, 2018
1 parent 20e53eb commit 7938bf1
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
2 changes: 1 addition & 1 deletion ipv8/attestation/trustchain/caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions ipv8/taskmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 0 additions & 3 deletions ipv8/test/test_taskmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7938bf1

Please sign in to comment.