diff -r 0238cc842805 Doc/library/sched.rst --- a/Doc/library/sched.rst Thu Dec 06 17:49:58 2012 -0500 +++ b/Doc/library/sched.rst Sat Dec 08 12:16:53 2012 +0200 @@ -58,7 +58,7 @@ :class:`scheduler` instances have the following methods and attributes: -.. method:: scheduler.enterabs(time, priority, action, argument=[], kwargs={}) +.. method:: scheduler.enterabs(time, priority, action, argument=(), kwargs=None) Schedule a new event. The *time* argument should be a numeric type compatible with the return value of the *timefunc* function passed to the constructor. @@ -67,7 +67,8 @@ Executing the event means executing ``action(*argument, **kwargs)``. *argument* must be a sequence holding the parameters for *action*. - *kwargs* must be a dictionary holding the keyword parameters for *action*. + *kwargs* must be a dictionary holding the keyword parameters for *action* + (an empty dictionary used if not specified). Return value is an event which may be used for later cancellation of the event (see :meth:`cancel`). @@ -79,7 +80,7 @@ *kwargs* parameter was added. -.. method:: scheduler.enter(delay, priority, action, argument=[], kwargs={}) +.. method:: scheduler.enter(delay, priority, action, argument=(), kwargs=None) Schedule an event for *delay* more time units. Other than the relative time, the other arguments, the effect and the return value are the same as those for diff -r 0238cc842805 Lib/sched.py --- a/Lib/sched.py Thu Dec 06 17:49:58 2012 -0500 +++ b/Lib/sched.py Sat Dec 08 12:16:53 2012 +0200 @@ -60,24 +60,28 @@ self.timefunc = timefunc self.delayfunc = delayfunc - def enterabs(self, time, priority, action, argument=[], kwargs={}): + def enterabs(self, time, priority, action, argument=(), kwargs=None): """Enter a new event in the queue at an absolute time. Returns an ID for the event which can be used to remove it, if necessary. """ + if kwargs is None: + kwargs = {} with self._lock: event = Event(time, priority, action, argument, kwargs) heapq.heappush(self._queue, event) return event # The ID - def enter(self, delay, priority, action, argument=[], kwargs={}): + def enter(self, delay, priority, action, argument=(), kwargs=None): """A variant that specifies the time as a relative time. This is actually the more commonly used interface. """ + if kwargs is None: + kwargs = {} with self._lock: time = self.timefunc() + delay return self.enterabs(time, priority, action, argument, kwargs)