Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use a partial function for the callback

  • Loading branch information...
commit 9357b4dce1d8f39d7fd9b1a3bf2cb819652ccdc0 1 parent 6d96f23
Alvaro authored

Showing 1 changed file with 3 additions and 6 deletions. Show diff stats Hide diff stats

  1. +3 6 evy/hubs/timer.py
9 evy/hubs/timer.py
@@ -56,8 +56,8 @@ def __init__(self, seconds, cb, *args, **kw):
56 56 calling timer.schedule() or runloop.add_timer(timer).
57 57 """
58 58 self.seconds = seconds
59   -
60   - self.callback = kw.pop('callback', partial(cb, *args, **kw))
  59 + if '_callback' in kw: self.callback = kw.pop('_callback')
  60 + else: self.callback = partial(cb, *args, **kw)
61 61
62 62 self.called = False
63 63
@@ -79,7 +79,7 @@ def __repr__(self):
79 79 return retval
80 80
81 81 def copy(self):
82   - return self.__class__(self.seconds, callback = self.callback)
  82 + return self.__class__(self.seconds, None, _callback = self.callback)
83 83
84 84 def schedule(self):
85 85 """
@@ -149,9 +149,6 @@ def __call__(self, *args):
149 149 def cancel(self):
150 150 """
151 151 Cancel the timer
152   -
153   - :return:
154   - :rtype:
155 152 """
156 153 self.greenlet = None
157 154 Timer.cancel(self)

0 comments on commit 9357b4d

Please sign in to comment.
Something went wrong with that request. Please try again.