Skip to content

Commit

Permalink
optimize device disconnected check
Browse files Browse the repository at this point in the history
  • Loading branch information
leng-yue committed Oct 26, 2022
1 parent c40f6e3 commit 01b2e65
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "scrcpy-client"
version = "0.4.5"
version = "0.4.6"
description = "A client of scrcpy"
authors = ["lengyue <lengyue@lengyue.me>"]
readme = "README.md"
Expand Down
18 changes: 15 additions & 3 deletions scrcpy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,22 @@ def stop(self) -> None:
"""
self.alive = False
if self.__server_stream is not None:
self.__server_stream.close()
try:
self.__server_stream.close()
except:
pass

if self.control_socket is not None:
self.control_socket.close()
try:
self.control_socket.close()
except:
pass

if self.__video_socket is not None:
self.__video_socket.close()
try:
self.__video_socket.close()
except:
pass

def __stream_loop(self) -> None:
"""
Expand All @@ -230,6 +241,7 @@ def __stream_loop(self) -> None:
self.__send_to_listeners(EVENT_FRAME, None)
except OSError as e: # Socket Closed
if self.alive:
self.stop()
raise e

def add_listener(self, cls: str, listener: Callable[..., Any]) -> None:
Expand Down

0 comments on commit 01b2e65

Please sign in to comment.