diff --git a/adb/test_device.py b/adb/test_device.py index b12bf88b5..2f2a823bf 100644 --- a/adb/test_device.py +++ b/adb/test_device.py @@ -473,8 +473,12 @@ class ShellTest(DeviceTest): self.device.shell(proc_query) os.kill(sleep_proc.pid, signal.SIGINT) sleep_proc.communicate() - self.assertEqual(1, self.device.shell_nocheck(proc_query)[0], - 'subprocess failed to terminate') + + # It can take some time for the process to receive the signal and die. + end_time = time.time() + 3 + while self.device.shell_nocheck(proc_query)[0] != 1: + self.assertFalse(time.time() > end_time, + 'subprocess failed to terminate in time') def test_non_interactive_stdin(self): """Tests that non-interactive shells send stdin."""