Skip to content

Commit

Permalink
bug fix for safe connect server (#127)
Browse files Browse the repository at this point in the history
* bug fix for safe connect server, when _adb._safe_connect:66 raising AdbTimeout, it will be failure.

* add error assertion

---------

Co-authored-by: ZERTIAN <[email protected]>
  • Loading branch information
pinnnkman and ZERTIAN authored May 27, 2024
1 parent 9facf46 commit e194766
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions adbutils/_adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ def _create_socket(self):
def _safe_connect(self):
try:
return self._create_socket()
except AdbTimeout:
pass
except AdbConnectionError:
flags = subprocess.CREATE_NO_WINDOW if os.name == 'nt' else 0
subprocess.run([adb_path(), "start-server"], timeout=20.0, creationflags=flags) # 20s should enough for adb start
return self._create_socket()
pass
flags = subprocess.CREATE_NO_WINDOW if os.name == 'nt' else 0
subprocess.run([adb_path(), "start-server"], timeout=20.0, creationflags=flags) # 20s should enough for adb start
return self._create_socket()

@property
def closed(self) -> bool:
Expand Down

0 comments on commit e194766

Please sign in to comment.