Open sunilangadi2 opened 6 years ago
Hi @sunilangadi2,
For local "workers", the nodelist will actually consists in local Worker instances (eg. WorkerPopen) if a worker "key" is not provided earlier.
For example, you can set a custom key when calling task.shell()
or task.run()
(here the key is "local"):
from ClusterShell.Task import task_self
task = task_self()
task.run("echo foo", key="local")
for buf, keys in task.iter_buffers():
for key in keys:
print(key, buf.message())
$ python test.py
('local', 'foo')
For remote workers (eg. task.shell(..., nodes=...)
, the keys will be the node names.
Hope that makes sense!
Thanks for your solution @thiell
Code:
result = {}
for output,nodelist in task.iter_buffers():
for node in nodelist:
result[node] = str(output)
this produces output
{<ClusterShell.Worker.Popen.WorkerPopen object at 0x7f919c13ded0>: "invalid parameter dump_kernel'\nopen(dump_kernel) failed: No such file or directory"}