1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
23
25 implements(IChangeSource)
26
27 master = None
28 "if C{self.running} is true, then C{cs.master} points to the buildmaster."
29
32
34 """
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 Any subclass will be available via the "poller" webhook.
40 """
41
42 pollInterval = 60
43 "time (in seconds) between calls to C{poll}"
44
45 _loop = None
46
47 - def __init__(self, name=None, pollInterval=60*10):
53
55 """
56 This is the method that is called by LoopingCall to actually poll.
57 It may also be called by change hooks to request a poll.
58 It is serialiazed - if you call it while a poll is in progress
59 then the 2nd invocation won't start until the 1st has finished.
60 """
61 d = defer.maybeDeferred(self.poll)
62 d.addErrback(log.err, 'while polling for changes')
63 return d
64
66 """
67 Perform the polling operation, and return a deferred that will fire
68 when the operation is complete. Failures will be logged, but the
69 method will be called again after C{pollInterval} seconds.
70 """
71
75
80
91
95