本文整理匯總了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()