Skip to content

Commit

Permalink
WorkerPopen: add missing key attribute (#343)
Browse files Browse the repository at this point in the history
In 1.6, WorkerPopen had a key attribute, which got lost in 1.7.

Restore key attribute and fix clush interactive !cmd.

Fixes #343.

Change-Id: I184d1bbeb3d665dce0527a8fd2526a0ac6707829
  • Loading branch information
thiell committed Aug 11, 2017
1 parent 20cecf8 commit b8bb118
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ClusterShell/Worker/Popen.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ def __init__(self, command, key=None, handler=None,
if not self.command:
raise ValueError("missing command parameter in WorkerPopen "
"constructor")
self.key = key

def retcode(self):
"""Return return code or None if command is still in progress."""
Expand Down
10 changes: 10 additions & 0 deletions tests/TaskLocalMixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1071,3 +1071,13 @@ def ev_read(self, worker):
self.assertEqual(worker1.node_retcode('localhost'), 0)
self.assertEqual(worker2.read(sname="pipe1"), b"test")
self.assertEqual(task_self().max_retcode(), 0)

def testWorkerPopenKeyCompat(self):
"""test WorkerPopen.key attribute (compat with 1.6)"""
# Was broken in 1.7 to 1.7.3 after StreamWorker changes
task = task_self()
worker = task.shell("echo ok", key="ok")
self.assertEqual(worker.key, "ok")
worker = WorkerPopen("echo foo", key="foo")
self.assertEqual(worker.key, "foo")
task.run()

0 comments on commit b8bb118

Please sign in to comment.