Package Task :: Module TimerTask
[hide private]
[frames] | no frames]

Source Code for Module Task.TimerTask

 1  ''' 
 2  Defines a L{Task} to execute when a timed interval passes. 
 3   
 4  @author: Peter Parente 
 5  @organization: IBM Corporation 
 6  @copyright: Copyright (c) 2005, 2007 IBM Corporation 
 7  @license: The BSD License 
 8   
 9  All rights reserved. This program and the accompanying materials are made  
10  available under the terms of the BSD license which accompanies 
11  this distribution, and is available at 
12  U{http://www.opensource.org/licenses/bsd-license.php} 
13  ''' 
14  import Base 
15   
16 -class TimerTask(Base.Task):
17 ''' 18 Executes when a timed interval passes. The interval should not be changed 19 once this L{Task} has been registered. Only the interval set at registration 20 time will be honored. 21 22 This class registers its name and whether it should be monitored by default 23 in an L{AEMonitor} using the L{Base.registerTaskType} 24 function when this module is first imported. The L{AEMonitor} 25 can use this information to build its menus. 26 27 @ivar interval: Interval for the timer in seconds 28 @type interval: integer 29 ''' 30 Base.registerTaskType('TimerTask', False) 31
32 - def __init__(self, ident, interval):
33 ''' 34 Stores the desired interval. 35 36 @note: Changed from second to millisecond resolution 37 38 @param interval: Interval for the timer in milliseconds 39 @type interval: integer 40 @param ident: Programmatic identifier 41 @type ident: string 42 ''' 43 Base.Task.__init__(self, ident) 44 self.interval = interval
45
46 - def getTimerInterval(self):
47 ''' 48 @return: Interval for this timer 49 @rtype: integer 50 ''' 51 return self.interval
52
53 - def execute(self, interval, layer, **kwargs):
54 ''' 55 Executes this L{Task} in response to a timer event. Called by 56 L{Tier.Tier._executeTask}. 57 58 @param interval: Interval in seconds on which the timer fires 59 @type interval: integer 60 @param layer: Layer on which the event occurred 61 @type layer: integer 62 ''' 63 pass
64