1
0
mirror of https://gitee.com/sui-feng-cb/AzurLaneAutoScript1 synced 2026-03-12 00:28:20 +08:00

Fix: Cleanup after subprocess.Popen.communicate()

This commit is contained in:
LmeSzinc
2022-06-07 01:35:53 +08:00
parent ebd6872358
commit db58202263
2 changed files with 14 additions and 3 deletions

View File

@@ -245,7 +245,13 @@ class Connection:
# No gooey anymore, just shell=False
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=False)
return process.communicate(timeout=timeout)[0]
try:
stdout, stderr = process.communicate(timeout=timeout)
except subprocess.TimeoutExpired:
process.kill()
stdout, stderr = process.communicate()
logger.warning(f'TimeoutExpired when calling {cmd}, stdout={stdout}, stderr={stderr}')
return stdout
def adb_shell(self, cmd, **kwargs):
"""