Trees | Indices | Help |
|
---|
|
1 # This file is part of Buildbot. Buildbot is free software: you can 2 # redistribute it and/or modify it under the terms of the GNU General Public 3 # License as published by the Free Software Foundation, version 2. 4 # 5 # This program is distributed in the hope that it will be useful, but WITHOUT 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 8 # details. 9 # 10 # You should have received a copy of the GNU General Public License along with 11 # this program; if not, write to the Free Software Foundation, Inc., 51 12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 13 # 14 # Copyright Buildbot Team Members 15 16 from zope.interface import implements 17 from twisted.application import service 18 from twisted.internet import defer, task, reactor 19 from twisted.python import log 20 21 from buildbot.interfaces import IChangeSource 22 from buildbot import util 2325 implements(IChangeSource) 26 27 master = None 28 "if C{self.running} is true, then C{cs.master} points to the buildmaster." 293234 """ 35 Utility subclass for ChangeSources that use some kind of periodic polling 36 operation. Subclasses should define C{poll} and set C{self.pollInterval}. 37 The rest is taken care of. 38 """ 39 40 pollInterval = 60 41 "time (in seconds) between calls to C{poll}" 42 43 _loop = None 4465 reactor.callWhenRunning(start_loop) 6646 """ 47 Perform the polling operation, and return a deferred that will fire 48 when the operation is complete. Failures will be logged, but the 49 method will be called again after C{pollInterval} seconds. 50 """5153 ChangeSource.startService(self) 54 def do_poll(): 55 d = defer.maybeDeferred(self.poll) 56 d.addErrback(log.err, 'while polling for changes') 57 return d58 59 # delay starting the loop until the reactor is running, and do not 60 # run it immediately - if services are still starting up, they may 61 # miss an initial flood of changes 62 def start_loop(): 63 self._loop = task.LoopingCall(do_poll) 64 self._loop.start(self.pollInterval, now=False)68 if self._loop and self._loop.running: 69 self._loop.stop() 70 return ChangeSource.stopService(self)71
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Mar 25 19:40:41 2012 | http://epydoc.sourceforge.net |