本文整理汇总了Python中twisted.application.service.Service类的典型用法代码示例。如果您正苦于以下问题:Python Service类的具体用法?Python Service怎么用?Python Service使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Service类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startService
def startService(self):
if self.loop != -1 or self._state == 'started':
msg(self.name, 'start fail - already started', system='-')
# Already started
return
# State
self._state = 'starting'
# Show info
msg(self.name, 'start', system='-')
# Cancel stop
if self._stopCall:
self._stopCall.cancel()
self._stopCall = None
# Call stop
self._stopDeferred.callback(0)
self._stopDeferred = None
Service.startService(self)
self.loop = 0
self._state = 'started'
# Start
for name, (run, interval) in self._runs.iteritems():
run.start(interval, now=False)
# Show info
msg(self.name, 'started', system='-')
示例2: stopService
def stopService(self):
print 'Stop PullRequest service: %s ...' % self.context.name
Service.stopService(self)
if self.watchLoop:
self.watchLoop.stop()
if self.schedulerLoop:
self.schedulerLoop.stop()
示例3: s2
def s2(code, self=self):
try:
if code != 1:
# Cancel stop
return
if not (self._state == 'stopping' and (self._process + self._workers) == 0):
err(RuntimeError('{0} stop error: state-{1} p{2} w{3}'.format(
self.name,
self._state,
self._process,
self._workers,
)))
self._stopCall = None
self._stopDeferred = None
# Inside
Service.stopService(self)
self._state = 'stopped'
# Show info
msg(self.name, 'stopped', system='-')
except:
err()
示例4: startService
def startService(self, _reactor=reactor):
assert not self._already_started, "can start the PullRequest service once"
self._already_started = True
Service.startService(self)
print 'PullRequest service starting: %s ...' % self.context.name
d = defer.Deferred()
_reactor.callWhenRunning(d.callback, None)
yield d
try:
from .serviceloops import PullRequestsWatchLoop, SchedulerLoop
self.watchLoop = PullRequestsWatchLoop(self.context)
yield self.watchLoop.start()
self.schedulerLoop = SchedulerLoop(self.context)
yield self.schedulerLoop.start();
except:
f = failure.Failure()
log.err(f, 'while starting PullRequest service: %s' % self.context.name)
_reactor.stop()
log.msg('PullRequest service is running: %s' % self.context.name)
示例5: stopService
def stopService(self):
ntasks = len(self._tasks)
for task in self.iterTasks():
task.close()
self._tasks = set()
Service.stopService(self)
logger.debug("stopped scheduler (%i tasks killed)" % ntasks)
示例6: startService
def startService(self):
"""
Called when the plugin is started. If a plugin needs to perform any
startup tasks, they should override this method (be sure to chain up
to the parent method) and perform them here.
"""
Service.startService(self)
示例7: stopService
def stopService(self):
if self.running:
Service.stopService(self)
log.info("Stopping master heartbeat service...")
return self._hb.stop()
else:
return defer.succeed(None)
示例8: startService
def startService(self):
"""
Make sure that the necessary properties are set on the root Flocker zfs
storage pool.
"""
Service.startService(self)
# These next things are logically part of the storage pool creation
# process. Since Flocker itself doesn't yet have any involvement with
# that process, it's difficult to find a better time/place to set these
# properties than here - ie, "every time we're about to interact with
# the storage pool". In the future it would be better if we could do
# these things one-off - sometime around when the pool is created or
# when Flocker is first installed, for example. Then we could get rid
# of these operations from this method (which eliminates the motivation
# for StoragePool being an IService implementation).
# https://clusterhq.atlassian.net/browse/FLOC-635
# Set the root dataset to be read only; IService.startService
# doesn't support Deferred results, and in any case startup can be
# synchronous with no ill effects.
_sync_command_error_squashed(
[b"zfs", b"set", b"readonly=on", self._name], self.logger)
# If the root dataset is read-only then it's not possible to create
# mountpoints in it for its child datasets. Avoid mounting it to avoid
# this problem. This should be fine since we don't ever intend to put
# any actual data into the root dataset.
_sync_command_error_squashed(
[b"zfs", b"set", b"canmount=off", self._name], self.logger)
示例9: startService
def startService(self):
Service.startService(self)
self.configuration.load()
self.connectionRegistry = \
ConnectionRegistry( self.createConfiguredDeviceMap())
self.timer.start(self.updateInterval).addErrback(log.err)
self.statusIcon.show()
示例10: startService
def startService(self):
Service.startService(self)
# Now we're ready to build the command lines and actualy add the
# processes to procmon. This step must be done prior to setting
# active to 1
for processObject, env in self.processObjects:
name = processObject.getName()
self.addProcess(
name,
processObject.getCommandLine(),
env=env
)
self._extraFDs[name] = processObject.getFileDescriptors()
self.active = 1
delay = 0
if config.MultiProcess.StaggeredStartup.Enabled:
delay_interval = config.MultiProcess.StaggeredStartup.Interval
else:
delay_interval = 0
for name in self.processes.keys():
if name.startswith("caldav"):
when = delay
delay += delay_interval
else:
when = 0
callLater(when, self.startProcess, name)
self.consistency = callLater(
self.consistencyDelay,
self._checkConsistency
)
示例11: stopService
def stopService(self):
"""
Stop the service by calling stored function
"""
Service.stopService(self)
if self._stop:
return self._stop()
示例12: startService
def startService(self):
## this implementation of startService overrides the original
if self.running:
return
Service.startService(self)
pingFunc, args, kwargs = self.call
def pingFail(failure):
failure.trap(defer.TimeoutError)
#print 'Call to %s timed out. Calling onTimeout and stopping service.' % (pingFunc.__name__,)
self.onTimeout()
self.stopService()
def sendPing():
self.ping = defer.Deferred()
## the pingFunc is assumed to be a syncronous function that
## sends the request along to the client and returns immediately.
## TODO: maybe assume that this returns a deferred that is fired when
## the response is received?
pingFunc(*args, **kwargs)
self.ping.addErrback(pingFail)
self.ping.setTimeout(self.step - 1) # timeout if no response before next iteration
return self.ping ## LoopingCall will reschedule as soon as this fires
self._loop = LoopingCall(sendPing)
self._loop.start(self.step, now=self.now).addErrback(self._failed)
示例13: startService
def startService(self):
Service.startService(self)
self._registered = False
self._timer_service = TimerService(
self.check_interval.total_seconds(), self._check_certs)
self._timer_service.clock = self._clock
self._timer_service.startService()
示例14: __init__
def __init__(self):
Service.__init__(self)
self.seq = -1
self.freq = 4000
self.mag = 15.0
self.tamb = 3
self.tsky = self.tamb - 30
示例15: startService
def startService(self):
Service.startService(self)
log.info("Starting RPC service...")
self.cleanSocket(None)
self._localPort=reactor.listenUNIX(core.cfg['UNIX_PORT'], pb.PBServerFactory(LocalRPC(self._master)))
self._remotePort=reactor.listenTCP(core.cfg['TCP_PORT'], pb.PBServerFactory(RemoteRPC(self._master)))