Skip to content

Commit

Permalink
Merge pull request #365 from qstokkink/fix_taskmanager_no_value
Browse files Browse the repository at this point in the history
Added support for delayed deferred with no value
  • Loading branch information
xoriole authored Nov 13, 2018
2 parents 20e53eb + 7938bf1 commit 8122e1b
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 8122e1b

Please sign in to comment.