本文整理汇总了Python中buildbot.process.buildrequestdistributor.BuildRequestDistributor类的典型用法代码示例。如果您正苦于以下问题:Python BuildRequestDistributor类的具体用法?Python BuildRequestDistributor怎么用?Python BuildRequestDistributor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BuildRequestDistributor类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, master):
service.AsyncMultiService.__init__(self)
self.setName("botmaster")
self.master = master
self.builders = {}
self.builderNames = []
# builders maps Builder names to instances of bb.p.builder.Builder,
# which is the master-side object that defines and controls a build.
# self.slaves contains a ready BuildSlave instance for each
# potential buildslave, i.e. all the ones listed in the config file.
# If the slave is connected, self.slaves[slavename].slave will
# contain a RemoteReference to their Bot instance. If it is not
# connected, that attribute will hold None.
self.slaves = {} # maps slavename to BuildSlave
self.watchers = {}
# self.locks holds the real Lock instances
self.locks = {}
# self.mergeRequests is the callable override for merging build
# requests
self.mergeRequests = None
self.shuttingDown = False
self.lastSlavePortnum = None
# subscription to new build requests
self.buildrequest_consumer = None
# a distributor for incoming build requests; see below
self.brd = BuildRequestDistributor(self)
self.brd.setServiceParent(self)
示例2: __init__
def __init__(self, master):
service.AsyncMultiService.__init__(self)
self.setName("botmaster")
self.master = master
self.builders = {}
self.builderNames = []
# builders maps Builder names to instances of bb.p.builder.Builder,
# which is the master-side object that defines and controls a build.
self.watchers = {}
# self.locks holds the real Lock instances
self.locks = {}
self.shuttingDown = False
self.lastSlavePortnum = None
# subscription to new build requests
self.buildrequest_consumer = None
# a distributor for incoming build requests; see below
self.brd = BuildRequestDistributor(self)
self.brd.setServiceParent(self)
示例3: BotMaster
class BotMaster(service.ReconfigurableServiceMixin, service.AsyncMultiService):
"""This is the master-side service which manages remote buildbot workers.
It provides them with Workers, and distributes build requests to
them."""
debug = 0
name = "botmaster"
def __init__(self):
service.AsyncMultiService.__init__(self)
self.builders = {}
self.builderNames = []
# builders maps Builder names to instances of bb.p.builder.Builder,
# which is the master-side object that defines and controls a build.
self.watchers = {}
# self.locks holds the real Lock instances
self.locks = {}
self.shuttingDown = False
# subscription to new build requests
self.buildrequest_consumer = None
# a distributor for incoming build requests; see below
self.brd = BuildRequestDistributor(self)
self.brd.setServiceParent(self)
@defer.inlineCallbacks
def cleanShutdown(self, quickMode=False, stopReactor=True, _reactor=reactor):
"""Shut down the entire process, once all currently-running builds are
complete.
quickMode will mark all builds as retry (except the ones that were triggered)
"""
if self.shuttingDown:
return
log.msg("Initiating clean shutdown")
self.shuttingDown = True
# first, stop the distributor; this will finish any ongoing scheduling
# operations before firing
yield self.brd.disownServiceParent()
# Double check that we're still supposed to be shutting down
# The shutdown may have been cancelled!
while self.shuttingDown:
if quickMode:
for builder in self.builders.values():
# As we stop the builds, builder.building might change during loop
# so we need to copy the list
for build in list(builder.building):
# if build is waited for then this is a sub-build, so
# no need to retry it
if sum(br.waitedFor for br in build.requests):
results = CANCELLED
else:
results = RETRY
is_building = build.workerforbuilder.state == States.BUILDING
build.stopBuild("Master Shutdown", results)
if not is_building:
# if it is not building, then it must be a latent worker
# which is substantiating. Cancel it.
build.workerforbuilder.worker.insubstantiate()
# then wait for all builds to finish
l = []
for builder in self.builders.values():
for build in builder.building:
l.append(build.waitUntilFinished())
if len(l) == 0:
log.msg("No running jobs, starting shutdown immediately")
else:
log.msg("Waiting for %i build(s) to finish" % len(l))
yield defer.DeferredList(l)
# Check that there really aren't any running builds
n = 0
for builder in self.builders.values():
if builder.building:
num_builds = len(builder.building)
log.msg("Builder %s has %i builds running" %
(builder, num_builds))
n += num_builds
if n > 0:
log.msg(
"Not shutting down, there are %i builds running" % n)
log.msg("Trying shutdown sequence again")
yield util.asyncSleep(1)
else:
if stopReactor and self.shuttingDown:
log.msg("Stopping reactor")
_reactor.stop()
break
if not self.shuttingDown:
yield self.brd.setServiceParent(self)
def cancelCleanShutdown(self):
"""Cancel a clean shutdown that is already in progress, if any"""
#.........这里部分代码省略.........
示例4: BotMaster
class BotMaster(config.ReconfigurableServiceMixin, service.AsyncMultiService):
"""This is the master-side service which manages remote buildbot slaves.
It provides them with BuildSlaves, and distributes build requests to
them."""
debug = 0
def __init__(self, master):
service.AsyncMultiService.__init__(self)
self.setName("botmaster")
self.master = master
self.builders = {}
self.builderNames = []
# builders maps Builder names to instances of bb.p.builder.Builder,
# which is the master-side object that defines and controls a build.
# self.slaves contains a ready BuildSlave instance for each
# potential buildslave, i.e. all the ones listed in the config file.
# If the slave is connected, self.slaves[slavename].slave will
# contain a RemoteReference to their Bot instance. If it is not
# connected, that attribute will hold None.
self.slaves = {} # maps slavename to BuildSlave
self.watchers = {}
# self.locks holds the real Lock instances
self.locks = {}
# self.mergeRequests is the callable override for merging build
# requests
self.mergeRequests = None
self.shuttingDown = False
self.lastSlavePortnum = None
# subscription to new build requests
self.buildrequest_consumer = None
# a distributor for incoming build requests; see below
self.brd = BuildRequestDistributor(self)
self.brd.setServiceParent(self)
def cleanShutdown(self, _reactor=reactor):
"""Shut down the entire process, once all currently-running builds are
complete."""
if self.shuttingDown:
return
log.msg("Initiating clean shutdown")
self.shuttingDown = True
# first, stop the distributor; this will finish any ongoing scheduling
# operations before firing
d = self.brd.stopService()
# then wait for all builds to finish
def wait(_):
l = []
for builder in self.builders.values():
for build in builder.builder_status.getCurrentBuilds():
l.append(build.waitUntilFinished())
if len(l) == 0:
log.msg("No running jobs, starting shutdown immediately")
else:
log.msg("Waiting for %i build(s) to finish" % len(l))
return defer.DeferredList(l)
d.addCallback(wait)
# Finally, shut the whole process down
def shutdown(ign):
# Double check that we're still supposed to be shutting down
# The shutdown may have been cancelled!
if self.shuttingDown:
# Check that there really aren't any running builds
for builder in self.builders.values():
n = len(builder.builder_status.getCurrentBuilds())
if n > 0:
log.msg("Not shutting down, builder %s has %i builds running" % (builder, n))
log.msg("Trying shutdown sequence again")
self.shuttingDown = False
self.cleanShutdown()
return
log.msg("Stopping reactor")
_reactor.stop()
else:
self.brd.startService()
d.addCallback(shutdown)
d.addErrback(log.err, 'while processing cleanShutdown')
def cancelCleanShutdown(self):
"""Cancel a clean shutdown that is already in progress, if any"""
if not self.shuttingDown:
return
log.msg("Cancelling clean shutdown")
self.shuttingDown = False
@metrics.countMethod('BotMaster.slaveLost()')
def slaveLost(self, bot):
metrics.MetricCountEvent.log("BotMaster.attached_slaves", -1)
#.........这里部分代码省略.........