本文整理汇总了Python中twisted.application.service.Service.stopService方法的典型用法代码示例。如果您正苦于以下问题:Python Service.stopService方法的具体用法?Python Service.stopService怎么用?Python Service.stopService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.application.service.Service
的用法示例。
在下文中一共展示了Service.stopService方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _sync_soledad
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def _sync_soledad(self):
"""
Synchronize with remote soledad.
:returns: a list of LeapDocuments, or None.
:rtype: iterable or None
"""
def _log_synced(result):
self.log.info('Sync finished')
return result
def _handle_invalid_auth_token_error(failure):
failure.trap(InvalidAuthTokenError)
self.log.warn('Sync failed because token is invalid: %r' % failure)
self.stopService()
emit_async(catalog.SOLEDAD_INVALID_AUTH_TOKEN, self._userid)
self.log.info('Starting sync...')
d = self._soledad.sync()
d.addCallbacks(_log_synced, _handle_invalid_auth_token_error)
return d
示例2: stopService
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def stopService(self):
"""
Stops the loop that fetches mail.
"""
if not self.running:
return
if self._loop and self._loop.running is True:
self._loop.stop()
self._loop = None
Service.stopService(self)
示例3: stopService
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def stopService(self):
Service.stopService(self)
return self.stop_result
示例4: test_wait_for_service_stop
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def test_wait_for_service_stop(self):
"""
The ``Deferred`` returned by ``main_for_service`` does not fire before
the ``Deferred`` returned by the service's ``stopService`` method
fires.
"""
result = main_for_service(self.reactor, AsyncStopService(Deferred()))
self._shutdown_reactor(self.reactor)
self.assertNoResult(result)
示例5: test_fire_after_service_stop
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def test_fire_after_service_stop(self):
"""
The ``Deferred`` returned by ``main_for_service`` fires once the
``Deferred`` returned by the service's ``stopService`` method fires.
"""
async = Deferred()
result = main_for_service(self.reactor, AsyncStopService(async))
self._shutdown_reactor(self.reactor)
async.callback(None)
self.assertIs(None, self.successResultOf(result))
示例6: stopService
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def stopService(self):
Service.stopService(self)
self.ready = False
self._registered = False
for d in list(self._waiting):
d.cancel()
self._waiting = []
return self._timer_service.stopService()
示例7: stopService
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def stopService(self):
if self.metric_interval > 0:
self.record_task.stop()
Service.stopService(self)
# avoid import circularities
示例8: stopService
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def stopService(self):
try:
file_cache_idxs = MetricCache.getAllFileCaches()
writeCachedDataPointsWhenStop(file_cache_idxs)
except Exception as e:
log.err('write error when stopping service: %s' % e)
Service.stopService(self)
示例9: stopService
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def stopService(self):
"""
Stop the writer thread, wait for it to finish.
"""
Service.stopService(self)
removeDestination(self)
self._reactor.callFromThread(self._reactor.stop)
return deferToThreadPool(
self._mainReactor, self._mainReactor.getThreadPool(), self._thread.join
)
示例10: stopService
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def stopService(self):
"""
Stop reading on the inherited port.
@return: a Deferred which fires after the last outstanding request is
complete.
"""
Service.stopService(self)
# XXX stopping should really be destructive, because otherwise we will
# always leak a file descriptor; i.e. this shouldn't be restartable.
self.reportingFactory.inheritedPort.stopReading()
# Let any outstanding requests finish
return self.reportingFactory.allConnectionsClosed()
示例11: stopService
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def stopService(self):
info("Stopping client...")
Service.stopService(self)
# If CTRL-C is pressed twice in a row, the second SIGINT actually
# kills us before subprocesses die, and that makes them hang around.
signal.signal(signal.SIGINT, signal.SIG_IGN)
done = self.watchdog.request_exit()
done.addBoth(lambda r: self._remove_pid())
return done
示例12: stopService
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def stopService(self):
# We don't need to call port.stopListening(), because the reactor
# shutdown sequence will do that for us.
Service.stopService(self)
logging.info("%s stopped with config %s" % (
self.service_name.capitalize(), self.config.get_config_filename()))
示例13: startService
# 需要导入模块: from twisted.application.service import Service [as 别名]
# 或者: from twisted.application.service.Service import stopService [as 别名]
def startService(self):
Service.startService(self)
bootstrap_list.bootstrap(data_path=self._config.data_path,
log_dir=self._config.log_dir)
if self._config.clones > 0:
# Let clones open an appropriate number of fds
setrlimit(RLIMIT_NOFILE, (self._config.clones * 100,
self._config.clones * 200))
# Increase the timeout of AMP's MethodCalls.
# XXX: we should find a better way to expose this knot, and
# not set it globally on the class
from landscape.lib.amp import MethodCallSender
MethodCallSender.timeout = 300
# Create clones log and data directories
for i in range(self._config.clones):
suffix = "-clone-%d" % i
bootstrap_list.bootstrap(
data_path=self._config.data_path + suffix,
log_dir=self._config.log_dir + suffix)
result = succeed(None)
result.addCallback(lambda _: self.watchdog.check_running())
def start_if_not_running(running_daemons):
if running_daemons:
error("ERROR: The following daemons are already running: %s"
% (", ".join(x.program for x in running_daemons)))
self.exit_code = 1
reactor.crash() # so stopService isn't called.
return
self._daemonize()
info("Watchdog watching for daemons.")
return self.watchdog.start()
def die(failure):
log_failure(failure, "Unknown error occurred!")
self.exit_code = 2
reactor.crash()
result.addCallback(start_if_not_running)
result.addErrback(die)
return result