本文整理汇总了Python中buildbot.status.slave.SlaveStatus.setPaused方法的典型用法代码示例。如果您正苦于以下问题:Python SlaveStatus.setPaused方法的具体用法?Python SlaveStatus.setPaused怎么用?Python SlaveStatus.setPaused使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buildbot.status.slave.SlaveStatus
的用法示例。
在下文中一共展示了SlaveStatus.setPaused方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AbstractBuildSlave
# 需要导入模块: from buildbot.status.slave import SlaveStatus [as 别名]
# 或者: from buildbot.status.slave.SlaveStatus import setPaused [as 别名]
#.........这里部分代码省略.........
def canStartBuild(self):
"""
I am called when a build is requested to see if this buildslave
can start a build. This function can be used to limit overall
concurrency on the buildslave.
Note for subclassers: if a slave can become willing to start a build
without any action on that slave (for example, by a resource in use on
another slave becoming available), then you must arrange for
L{maybeStartBuildsForSlave} to be called at that time, or builds on
this slave will not start.
"""
if self.slave_status.isPaused():
return False
# If we're waiting to shutdown gracefully, then we shouldn't
# accept any new jobs.
if self.slave_status.getGraceful():
return False
if self.max_builds:
active_builders = [sb for sb in self.slavebuilders.values()
if sb.isBusy()]
if len(active_builders) >= self.max_builds:
return False
if not self.locksAvailable():
return False
return True
def _mail_missing_message(self, subject, text):
# first, see if we have a MailNotifier we can use. This gives us a
# fromaddr and a relayhost.
buildmaster = self.botmaster.master
for st in buildmaster.status:
if isinstance(st, MailNotifier):
break
else:
# if not, they get a default MailNotifier, which always uses SMTP
# to localhost and uses a dummy fromaddr of "buildbot".
log.msg("buildslave-missing msg using default MailNotifier")
st = MailNotifier("buildbot")
# now construct the mail
m = Message()
m.set_payload(text)
m['Date'] = formatdate(localtime=True)
m['Subject'] = subject
m['From'] = st.fromaddr
recipients = self.notify_on_missing
m['To'] = ", ".join(recipients)
d = st.sendMessage(m, recipients)
# return the Deferred for testing purposes
return d
def _gracefulChanged(self, graceful):
"""This is called when our graceful shutdown setting changes"""
self.maybeShutdown()
@defer.inlineCallbacks
def shutdown(self):
"""Shutdown the slave"""
if not self.conn:
log.msg("no remote; slave is already shut down")
return
yield self.conn.remoteShutdown()
def maybeShutdown(self):
"""Shut down this slave if it has been asked to shut down gracefully,
and has no active builders."""
if not self.slave_status.getGraceful():
return
active_builders = [sb for sb in self.slavebuilders.values()
if sb.isBusy()]
if active_builders:
return
d = self.shutdown()
d.addErrback(log.err, 'error while shutting down slave')
def _pauseChanged(self, paused):
if paused is True:
self.botmaster.master.status.slavePaused(self.slavename)
else:
self.botmaster.master.status.slaveUnpaused(self.slavename)
def pause(self):
"""Stop running new builds on the slave."""
self.slave_status.setPaused(True)
def unpause(self):
"""Restart running new builds on the slave."""
self.slave_status.setPaused(False)
self.botmaster.maybeStartBuildsForSlave(self.slavename)
def isPaused(self):
return self.slave_status.isPaused()
示例2: AbstractBuildSlave
# 需要导入模块: from buildbot.status.slave import SlaveStatus [as 别名]
# 或者: from buildbot.status.slave.SlaveStatus import setPaused [as 别名]
#.........这里部分代码省略.........
else:
# if not, they get a default MailNotifier, which always uses SMTP
# to localhost and uses a dummy fromaddr of "buildbot".
log.msg("buildslave-missing msg using default MailNotifier")
st = MailNotifier("buildbot")
# now construct the mail
m = Message()
m.set_payload(text)
m['Date'] = formatdate(localtime=True)
m['Subject'] = subject
m['From'] = st.fromaddr
recipients = self.notify_on_missing
m['To'] = ", ".join(recipients)
d = st.sendMessage(m, recipients)
# return the Deferred for testing purposes
return d
def _gracefulChanged(self, graceful):
"""This is called when our graceful shutdown setting changes"""
self.maybeShutdown()
@defer.inlineCallbacks
def shutdown(self):
"""Shutdown the slave"""
if not self.slave:
log.msg("no remote; slave is already shut down")
return
# First, try the "new" way - calling our own remote's shutdown
# method. The method was only added in 0.8.3, so ignore NoSuchMethod
# failures.
def new_way():
d = self.slave.callRemote('shutdown')
d.addCallback(lambda _ : True) # successful shutdown request
def check_nsm(f):
f.trap(pb.NoSuchMethod)
return False # fall through to the old way
d.addErrback(check_nsm)
def check_connlost(f):
f.trap(pb.PBConnectionLost)
return True # the slave is gone, so call it finished
d.addErrback(check_connlost)
return d
if (yield new_way()):
return # done!
# Now, the old way. Look for a builder with a remote reference to the
# client side slave. If we can find one, then call "shutdown" on the
# remote builder, which will cause the slave buildbot process to exit.
def old_way():
d = None
for b in self.slavebuilders.values():
if b.remote:
d = b.remote.callRemote("shutdown")
break
if d:
log.msg("Shutting down (old) slave: %s" % self.slavename)
# The remote shutdown call will not complete successfully since the
# buildbot process exits almost immediately after getting the
# shutdown request.
# Here we look at the reason why the remote call failed, and if
# it's because the connection was lost, that means the slave
# shutdown as expected.
def _errback(why):
if why.check(pb.PBConnectionLost):
log.msg("Lost connection to %s" % self.slavename)
else:
log.err("Unexpected error when trying to shutdown %s" % self.slavename)
d.addErrback(_errback)
return d
log.err("Couldn't find remote builder to shut down slave")
return defer.succeed(None)
yield old_way()
def maybeShutdown(self):
"""Shut down this slave if it has been asked to shut down gracefully,
and has no active builders."""
if not self.slave_status.getGraceful():
return
active_builders = [sb for sb in self.slavebuilders.values()
if sb.isBusy()]
if active_builders:
return
d = self.shutdown()
d.addErrback(log.err, 'error while shutting down slave')
def pause(self):
"""Stop running new builds on the slave."""
self.slave_status.setPaused(True)
def unpause(self):
"""Restart running new builds on the slave."""
self.slave_status.setPaused(False)
self.botmaster.maybeStartBuildsForSlave(self.slavename)
def isPaused(self):
return self.paused