utils/android: Fix race condition in LogcatMonitor
If you call .start then immediately call .stop, the thread may not
yet have set ._logcat, resulting in an AttributeError.
I initially fixed this by setting _logcat = None in __init__, then putting the
`kill` calls inside `if self._logcat`. The problem with this, as pointed out by
@valschneider, is that we can then have this sequence:
main thread: monitor thread
stop() run()
if self._logcat: .
# False, don't kill process .
join() .
self._logcat = <...>
Therefore, just have the stop() method wait until the process is started before
unconditionally killing it.
1 file changed