(serial)
| 506 | # We're more likely to miss the PID because it's shorter-lived, so there's a |
| 507 | # workaround in PythonSuite.kt to stop it being *too* short-lived. |
| 508 | async def find_pid(serial): |
| 509 | print("Waiting for app to start - this may take several minutes") |
| 510 | shown_error = False |
| 511 | while True: |
| 512 | try: |
| 513 | # `pidof` requires API level 24 or higher. The level 23 emulator |
| 514 | # includes it, but it doesn't work (it returns all processes). |
| 515 | pid = (await async_check_output( |
| 516 | adb, "-s", serial, "shell", "pidof", "-s", APP_ID |
| 517 | )).strip() |
| 518 | except CalledProcessError as e: |
| 519 | # If the app isn't running yet, pidof gives no output. So if there |
| 520 | # is output, there must have been some other error. However, this |
| 521 | # sometimes happens transiently, especially when running a managed |
| 522 | # emulator for the first time, so don't make it fatal. |
| 523 | if (e.stdout or e.stderr) and not shown_error: |
| 524 | print_called_process_error(e) |
| 525 | print("This may be transient, so continuing to wait") |
| 526 | shown_error = True |
| 527 | else: |
| 528 | # Some older devices (e.g. Nexus 4) return zero even when no process |
| 529 | # was found, so check whether we actually got any output. |
| 530 | if pid: |
| 531 | print(f"PID: {pid}") |
| 532 | return pid |
| 533 | |
| 534 | # Loop fairly rapidly to avoid missing a short-lived process. |
| 535 | await asyncio.sleep(0.2) |
| 536 | |
| 537 | |
| 538 | async def logcat_task(context, initial_devices): |
no test coverage detected
searching dependent graphs…