本文整理汇总了Python中ClusterShell.Worker.Worker.DistantWorker._set_task方法的典型用法代码示例。如果您正苦于以下问题:Python DistantWorker._set_task方法的具体用法?Python DistantWorker._set_task怎么用?Python DistantWorker._set_task使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClusterShell.Worker.Worker.DistantWorker
的用法示例。
在下文中一共展示了DistantWorker._set_task方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _set_task
# 需要导入模块: from ClusterShell.Worker.Worker import DistantWorker [as 别名]
# 或者: from ClusterShell.Worker.Worker.DistantWorker import _set_task [as 别名]
def _set_task(self, task):
"""
Bind worker to task. Called by task.schedule().
WorkerTree metaworker: override to schedule sub-workers.
"""
##if fanout is None:
## fanout = self.router.fanout
##self.task.set_info('fanout', fanout)
DistantWorker._set_task(self, task)
# Now bound to task - initalize router
self.topology = self.topology or task.topology
self.router = self.router or task._default_router()
# And launch stuffs
next_hops = self._distribute(self.task.info("fanout"), self.nodes)
for gw, targets in next_hops.iteritems():
if gw == targets:
self.logger.debug('task.shell cmd=%s nodes=%s timeout=%d' % \
(self.command, self.nodes, self.timeout))
self._child_count += 1
self._target_count += len(targets)
self.workers.append(self.task.shell(self.command,
nodes=targets, timeout=self.timeout,
handler=self.metahandler, stderr=self.stderr, tree=False))
else:
self._execute_remote(self.command, targets, gw, self.timeout)
示例2: _set_task
# 需要导入模块: from ClusterShell.Worker.Worker import DistantWorker [as 别名]
# 或者: from ClusterShell.Worker.Worker.DistantWorker import _set_task [as 别名]
def _set_task(self, task):
"""
Bind worker to task. Called by task.schedule().
WorkerTree metaworker: override to schedule sub-workers.
"""
##if fanout is None:
## fanout = self.router.fanout
##self.task.set_info('fanout', fanout)
DistantWorker._set_task(self, task)
# Now bound to task - initalize router
self.topology = self.topology or task.topology
self.router = self.router or task._default_router()
self._launch(self.nodes)
self._check_ini()