add pipe_duplex for socket <-> websocket#65
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces bidirectional pipe functionality for async socket and WebSocket communication, enabling data transfer between different connection types. The implementation adds a new pipe.py module with protocol definitions and wrapper classes.
Key Changes:
- Added
pipe_duplex()function andAsyncDuplexProtocol for async bidirectional I/O - Implemented
SocketDuplexandWebSocketDuplexwrapper classes for unified async interfaces - Updated type annotations in
android.pyto accurately reflect return types
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 16 comments.
| File | Description |
|---|---|
| uiautodev/remote/pipe.py | New module implementing async duplex piping with Protocol definition and socket/WebSocket wrapper classes |
| uiautodev/router/android.py | Added Union type import and updated shell function return type annotation |
| uiautodev/remote/scrcpy.py | Minor formatting improvement (added blank line) |
| uiautodev/command_proxy.py | Added redundant int() casts for additional type safety in tap coordinates |
Comments suppressed due to low confidence (3)
uiautodev/remote/pipe.py:79
- Except block directly handles BaseException.
except:
uiautodev/remote/pipe.py:84
- Except block directly handles BaseException.
except:
uiautodev/remote/pipe.py:139
- 'except' clause does nothing but pass and there is no explanatory comment.
except Exception:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| except Exception: | ||
| pass No newline at end of file |
There was a problem hiding this comment.
Bare except Exception: without logging or handling the specific exception makes debugging difficult. Consider logging the exception or handling specific exception types (e.g., ConnectionError, RuntimeError) for better error visibility.
|
|
||
| import logging | ||
| from typing import Dict, Optional | ||
| from typing import Dict, Optional, Union |
There was a problem hiding this comment.
Import of 'Dict' is not used.
Import of 'Optional' is not used.
| from typing import Dict, Optional, Union | |
| from typing import Union |
uiautodev/remote/pipe.py
Outdated
| except: | ||
| pass | ||
| if not self._same: | ||
| try: | ||
| self.wsock.close() | ||
| except: |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| except: | |
| pass | |
| if not self._same: | |
| try: | |
| self.wsock.close() | |
| except: | |
| except: | |
| # Ignore exceptions during socket close (e.g., already closed) | |
| pass | |
| if not self._same: | |
| try: | |
| self.wsock.close() | |
| except: | |
| # Ignore exceptions during socket close (e.g., already closed) |
uiautodev/remote/pipe.py
Outdated
| except: | ||
| pass | ||
| if not self._same: | ||
| try: | ||
| self.wsock.close() | ||
| except: |
There was a problem hiding this comment.
'except' clause does nothing but pass and there is no explanatory comment.
| except: | |
| pass | |
| if not self._same: | |
| try: | |
| self.wsock.close() | |
| except: | |
| except: | |
| # Ignore errors during rsock close; socket may already be closed or invalid. | |
| pass | |
| if not self._same: | |
| try: | |
| self.wsock.close() | |
| except: | |
| # Ignore errors during wsock close; socket may already be closed or invalid. |
uiautodev/remote/scrcpy3.py
Outdated
|
|
||
| def _start_scrcpy3(self): | ||
| device = self._device | ||
| version = self.VERSION |
There was a problem hiding this comment.
version = self.VERSION,这个version没用上
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
No description provided.