utah-client run_cmd looses output

Bug #1187068 reported by Andy Doan
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
UTAH
Fix Released
High
Andy Doan

Bug Description

we have an odd timing/race issue with the run_cmd implementation. I've added a simple test to test_common.py that repeats it pretty frequently:

def test_run_output(self):
        """Ensure run_cmd returns proper output."""
        result = run_cmd('echo 1')
        self.assertEqual(result['stdout'], '1\n')

Most of the timeout result['stdout'] is an empty string. If you add a small pause and then an extra check for stdout like:
@@ -219,6 +219,14 @@ def run_cmd(command, cwd=None, timeout=0, cmd_type=CMD_TC_T
                 stderr.write(stderr_tmp)
             except Empty:
                 pass
+ try:
+ print "one more read"
+ stdout_tmp = _normalize_encoding(outq.get_nowait())
+ syslog.syslog(stdout_tmp)
+ stdout.write(stdout_tmp)
+ except Empty:
+ print 'no data'
+ pass

Things magically work. We've been debating re-implementing this in a proper way. i think now is the time, and I'll do it today

Related branches

Andy Doan (doanac)
Changed in utah:
assignee: nobody → Andy Doan (doanac)
importance: Undecided → High
Andy Doan (doanac)
Changed in utah:
milestone: none → 0.13
status: New → In Progress
Andy Doan (doanac)
Changed in utah:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.