Open Bug 928034 Opened 11 years ago Updated 2 years ago

mozrunner.wait() can return before mozprocess.start() has finished processing the output


(Testing :: Mozbase, defect)



(Not tracked)


(Reporter: jgriffin, Unassigned)



When mozrunner.start() is called, it kicks off a separate thread to process the output; then mozrunner.wait() is used to wait until the process terminates, e.g.

self.runner = B2GRunner(**runner_args)
status = self.runner.wait()

Since wait() uses an entirely different mechanism than start() to determine if a process has finished, and because start() kicks off a separate thread, it's quite likely that wait() will return before start() has finished processing the process's output.

In the pattern above, this can lead to different threads writing to stdout at the same time, mangling the output, e.g., (from bug 807282):

15:52:30     INFO -  1968 INFO Passed:  1176
15:53:38     INFO -  1969 INFO FailedMochitest INFO | | Running tests: end.
15:53:41     INFO -  :  0
15:53:41     INFO -  1970 INFO Todo:    1
I'm not really sure how this scenario would be possible. The mozprocess.wait method waits for the output thread to stop running before it will return:

In bug 917252 we saw a similar case where the on_timeout callback printed a message that was interleaved with the test output, even though the callback was called with the same output thread.
Hmm, you're that case, maybe it's just a buffering/flushing issue?
Apparently it is a flushing issue; I was able to make a hacky fix to this problem with this:
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.