Open Bug 968446 Opened 6 years ago Updated 6 years ago
[mozprocess] Update poll() and wait() methods to return a better value if the process hasn't been started yet
As the question came up twice on bug 965326 we agreed on to spun of a new bug for it. As of now the poll() and wait() methods on the ProcessHandler class are throwing an exception when the process hasn't been started yet. Andrew and Ted think that we should better return None in such cases. But that would mean that consumers might think that the process is running while it does not. Not sure if that could be a larger problem. At least in mozrunner we are racing a specific exception in such a case: https://github.com/mozilla/mozbase/blob/master/mozrunner/mozrunner/base.py#L57
Ted said: > Pushing that to a followup is fine. Do you really think callers need to > discern between "hasn't started" and "still running" by using poll()? For > comparison, subprocess.Popen's poll/returncode just returns None "if the > process hasn't terminated yet": > http://docs.python.org/2/library/subprocess.html#subprocess.Popen.returncode Thing is that with the basic subprocess Popen command you will get directly the returncode because the process gets started immediately. In case of our process handler, you will have to call the run() method to actually start the process.
I don't think .poll() is the place to expose that distinction. I'd be fine with an is_running() or has_started() or something. I especially don't like that .poll will raise an exception if the process hasn't started yet.
You need to log in before you can comment on or make changes to this bug.