mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-09 16:19:03 +08:00
Fix: Cleanup after subprocess.Popen.communicate()
This commit is contained in:
parent
ebd6872358
commit
db58202263
@ -184,10 +184,15 @@ class EmulatorConnect:
|
||||
def __init__(self, adb='adb.exe'):
|
||||
self.adb_binary = adb
|
||||
|
||||
def _execute(self, cmd):
|
||||
def _execute(self, cmd, timeout=10):
|
||||
print(' '.join(cmd))
|
||||
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
|
||||
stdout, stderr = process.communicate(timeout=10)
|
||||
try:
|
||||
stdout, stderr = process.communicate(timeout=timeout)
|
||||
except subprocess.TimeoutExpired:
|
||||
process.kill()
|
||||
stdout, stderr = process.communicate()
|
||||
print(f'TimeoutExpired, stdout={stdout}, stderr={stderr}')
|
||||
return stdout
|
||||
|
||||
@cached_property
|
||||
|
||||
@ -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):
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user