Package etl :: Package component :: Package control :: Module sleep'
[hide private]
[frames] | no frames]

Source Code for Module etl.component.control.sleep'

 1  # -*- encoding: utf-8 -*- 
 2  ############################################################################## 
 3  # 
 4  #    ETL system- Extract Transfer Load system 
 5  #    Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved 
 6  #    $Id$ 
 7  # 
 8  #    This program is free software: you can redistribute it and/or modify 
 9  #    it under the terms of the GNU General Public License as published by 
10  #    the Free Software Foundation, either version 3 of the License, or 
11  #    (at your option) any later version. 
12  # 
13  #    This program is distributed in the hope that it will be useful, 
14  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
15  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
16  #    GNU General Public License for more details. 
17  # 
18  #    You should have received a copy of the GNU General Public License 
19  #    along with this program.  If not, see <http://www.gnu.org/licenses/>. 
20  # 
21  ############################################################################## 
22  """ 
23   Puts job process in sleep. 
24   
25   Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).  
26   GNU General Public License. 
27   
28  """ 
29   
30  from etl.component import component 
31  import time 
32   
33 -class sleep(component):
34 """ 35 Puts job process in sleep. 36 """
37 - def __init__(self, delay=1, name='component.control.sleep'):
38 """ 39 Parameters 40 delay : Delay in Seconds 41 name : Name of Component. 42 """ 43 super(sleep, self).__init__(name) 44 self._type = 'component.control.sleep' 45 self.delay = delay
46
47 - def __copy__(self):
48 res = sleep(self.delay, self.name) 49 return res
50
51 - def process(self):
52 for channel, trans in self.input_get().items(): 53 for iterator in trans: 54 for d in iterator: 55 time.sleep(self.delay) 56 yield d, 'main'
57