Permalink
Browse files

Use a partial function for the callback

  • Loading branch information...
1 parent 6d96f23 commit 9357b4dce1d8f39d7fd9b1a3bf2cb819652ccdc0 Alvaro committed Nov 12, 2012
Showing with 3 additions and 6 deletions.
  1. +3 −6 evy/hubs/timer.py
View
@@ -56,8 +56,8 @@ def __init__(self, seconds, cb, *args, **kw):
calling timer.schedule() or runloop.add_timer(timer).
"""
self.seconds = seconds
-
- self.callback = kw.pop('callback', partial(cb, *args, **kw))
+ if '_callback' in kw: self.callback = kw.pop('_callback')
+ else: self.callback = partial(cb, *args, **kw)
self.called = False
@@ -79,7 +79,7 @@ def __repr__(self):
return retval
def copy(self):
- return self.__class__(self.seconds, callback = self.callback)
+ return self.__class__(self.seconds, None, _callback = self.callback)
def schedule(self):
"""
@@ -149,9 +149,6 @@ def __call__(self, *args):
def cancel(self):
"""
Cancel the timer
-
- :return:
- :rtype:
"""
self.greenlet = None
Timer.cancel(self)

0 comments on commit 9357b4d

Please sign in to comment.