Provide comprehensive documentation, refactor RPC, and add unit tests#7
Draft
ArthurLuciani2 wants to merge 3 commits intodevelopfrom
Draft
Provide comprehensive documentation, refactor RPC, and add unit tests#7ArthurLuciani2 wants to merge 3 commits intodevelopfrom
ArthurLuciani2 wants to merge 3 commits intodevelopfrom
Conversation
- Introduced `test/test_RPC_registry.py` with comprehensive unit tests covering: - Device registration, lifecycle, and overwrite protection in `DeviceRegistry`. - Core `RPC` functionalities, including method calls, property handling, signal propagation, and unknown method handling. - Robustness tests for handling server restarts, client-server reconnections, and registry crashes. - Added mock server and client implementations (`TestDevice` and `TestClientProxy`) to simulate `RPCServer` and `RPCClient` behaviors for testing. - Designed failure scenarios for completeness, highlighting areas needing improvement in `RPCServer` lifecycle and client timeout handling.
- Added detailed class docstrings to `RPCSignal` and `RPCProperty` with usage examples and parameter explanations. - Introduced weak reference handling in `RPCSignal`, ensuring proper garbage collection and preventing memory leaks. - Improved signal emission behavior by verifying callable validity before invocation. - Enhanced type annotations and validation in `RPCSignal` to support modern Python type hints. - Refactored `RPCServer.serve_forever` to delegate event handling to dedicated methods for better readability and maintainability. - Consolidated repeated traceback printing into a new static method `_print_traceback_from_remote`. - Replaced several warning logs with error logs to signify critical issues more clearly. - Updated `RPCServer` to raise exceptions during serious errors (e.g., unreachable proxy) instead of returning warnings.
- Added comprehensive module-level docstrings in `RPC.py` to describe the RPC framework, its components, and usage. - Introduced detailed class docstrings for `RPCClient`, `RPCServer`, `RPCSignalReceiver`, `RPCProperty`, `RPCSignal`, and `NoResult`. - Improved method docstrings across multiple classes to include parameter descriptions, return types, and raised exceptions. - Added `__all__` in `RPC.py` to explicitly define public exports for the module. - Enhanced existing code by clarifying lifecycle behaviors, event handling, and error scenarios in various methods.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request includes the following changes:
RPC.pyincluding parameter descriptions, usage examples, and public interface definitions. Updated code comments for better clarity.RPCServerand introduced enhancements toRPCSignal, such as weak reference handling and improved callable validation. Centralized traceback logging and improved logging consistency.RPCfunctionalities,DeviceRegistry, and failure scenarios. Tests simulate real-world usage with mock implementations and capture edge cases related to server lifecycle and reconnection.