(*args, **kwargs)
| 419 | # and they will always be cleaned up on exit. |
| 420 | @asynccontextmanager |
| 421 | async def async_process(*args, **kwargs): |
| 422 | process = await asyncio.create_subprocess_exec(*args, **kwargs) |
| 423 | try: |
| 424 | yield process |
| 425 | finally: |
| 426 | if process.returncode is None: |
| 427 | # Allow a reasonably long time for Gradle to clean itself up, |
| 428 | # because we don't want stale emulators left behind. |
| 429 | timeout = 10 |
| 430 | process.terminate() |
| 431 | try: |
| 432 | await wait_for(process.wait(), timeout) |
| 433 | except TimeoutError: |
| 434 | print( |
| 435 | f"Command {args} did not terminate after {timeout} seconds " |
| 436 | f" - sending SIGKILL" |
| 437 | ) |
| 438 | process.kill() |
| 439 | |
| 440 | # Even after killing the process we must still wait for it, |
| 441 | # otherwise we'll get the warning "Exception ignored in __del__". |
| 442 | await wait_for(process.wait(), timeout=1) |
| 443 | |
| 444 | |
| 445 | async def async_check_output(*args, **kwargs): |
no test coverage detected
searching dependent graphs…